Friday, 15 December 2017

APEX Interview Questions


1. How can you done changes in apex trigger direct in production?
This is not possible direct in production first you need to done changes in sandbox then deploy it to production.

2. When should you build solutions declaratively instead of with code?
As a salesforce best practice, if something can be done using Configurations (Declarative) then its preferred over coding. The declarative framework is optimized for the platform and is always preffered.

3. Explain how MVC architecture fit for Salesforce?
In salesforce, Apex Classes works as Controllers, Visualforce Pages works as View and Custom objects works as Model.

4. Explain Apex Data Types?
Apex primitive data types include
• String
• Blob (for storing binary data)
• Boolean
• Date, DateTime and Time
• Integer, Long, Decimal, Double
• ID (Force.com database record identifier)

Example:
• DateTime dt = System.now() + 1;
• Boolean isClosed = true;
• String sCapsFirstName = ‘Andrew’.toUpperCase();

Apex sObject Types
Sobject (object representing a Force.com standard or custom object)

Example:
• Account acct = new Account(); //Sobject example

Apex has the following types of collections
• Lists
• Maps
• Sets

Example:
• List myList = new List();
• myList.add(12); //Add the number 12 to the list
• myList.get(0); //Access to first integer stored in the List

Enums
• Enum (or enumerated list) is an abstract that stores one value of a finite set of specified identifiers.
• To define an Enum, use enum keyword in the variable declaration and then define the list of values.
• By creating this Enum, you have created a new data type called Season that can be used as any other data type.

Example:
• public enum Season {WINTER, SPRING, SUMMER, FALL}

5. Explain Apex Variables?
Local variables are declared with Java-style syntax.
For example:
• Integer i = 0;
• String str;
• Account a;
• Account[] accts;
• Set s;
• Map m;

6. Apex and java similarties and differences?
Apex vs. Java: Similarties

• Both have classes, inheritance, polymorphism, and other common OOP features.
• Both have the same name variable, expression, and looping syntax.
• Both have the same block and conditional statement syntax.
• Both use the same object, array, and comment notation.
• Both are compiled, strongly-typed, and transactional.

Apex vs. Java: Differences

• Apex runs in a multi-tenant environment and is very controlled in its invocation and governor limits.
• To avoid confusion with case-insensitive SOQL queries, Apex is also case-insensitive.
• Apex is on-demand and is compiled and executed in cloud.
• Apex is not a general-purpose programming language but is instead a proprietary language used for specific business logic functions.
• Apex requires unit testing for development into a production environment.

7. Explain what is Trigger?
Trigger is a code that is executed before or after the record is updated or inserted.

8. When we Use a Before Trigger and After Trigger?
use "before" triggers to validate data or update fields on the same object.
use "after" triggers to update parent or related records.

9. If salesforce allow use to update the same object or validate the same object using before and after both trigger event so why before trigger exist?
If any thing is possible in same object without Soql using before trigger event so why we go for a after trigger event.

10. What is the maximum batch size in a single trigger execution?
Default batch size is 200 ,However maximum batch size is 2000.

11. If one object in salesforce have 2 triggers which runs “before Insert”. Is there any way to control the sequence of execution of these triggers?
Salesforce.com has documented that trigger sequence cannot be predefined. As a best practice create one trigger per object and use comment blocks to separate different logic blocks.

12. What are the trigger context variables?
To capture the runtime information we use trigger context variables.

Below context variables will return either true or false.
Trigger.isBefore (returns true if the trigger context is Before Mode)
Trigger.isAfter (returns true if the trigger context is After Mode)
Trigger.isInsert (returns true if the trigger context is Insert)
Trigger.isUpdate (returns true if the trigger context is Update)
Trigger.isDelete (returns true if the trigger context is Delete)
Trigger.isUndelete (returns true if the trigger context is Undelete)
Trigger.isExecuting (returns true if the apex class method is getting call from Apex Trigger)

Below context variables will store records at runtime.
trigger.old (stores history (old versions) of the records.)
trigger.oldMap (stores history (old versions) of the records along with id.)
trigger.new (stores new version of the records.)
trigger.newMap (stores new version of the records along with id.)

13. What are the recursive triggers and how to avoid?
If we perform update operation on the record in after update event logic recursive triggers will arise.
Using static boolean variable in an apex class (we should not keep static boolean variable inside of the trigger) we can avoid recursive triggers.

14. What is MIXED-DML-OPERATION error and how to avoid?
If we perform DML operation on standard/custom object and global objects(User, UserRole, Group, GroupMember, Permission Set, etc...) in same transaction this error will come.

To avoid this error, we should perform DML operation on standard/custom object records in a different transaction.

In general all the apex classes and apex triggers execute synchronously (execute immediately).

if we perform DML operation on standard/custom object records asynchronously (execute in future context), we can avoid MIXED-DML-OPERATION error.

To execute logic asynchronously keep the logic in an apex method (in a separate apex class, not in same apex trigger) which is decorated with @future annotation.

15. What Is The Difference Between Trigger.new And Trigger.old In Apex – Sfdc?
Trigger.new:

Returns a list of the new versions of the sObject records
Note that this sObject list is only available in insert and update triggers
i.e., Trigger.new is available in before insert, after insert, before update and after update
In Trigger.new the records can only be modified in before triggers.

Trigger.old:

Returns a list of the old versions of the sObject records
Note that this sObject list is only available in update and delete triggers.
i.e., Trigger.old is available in after insert, after update, before delete and after update.

16. What is the difference between trigger.new and trigger.newmap?
Trigger.new returns a list of the new versions of the sObject records.

Trigger.newMap returns a list of the new versions of the sObject records with the ids.

17. How to run trigger asynchronuosly?
If you use @future method trigger will run asynchronously.

18.What is the best practice of trigger?
1. One Trigger Per Object
A single Apex Trigger is all you need for one particular object. If you develop multiple Triggers for a single object, you have no way of controlling the order of execution if those Triggers can run in the same contexts

2. Logic-less Triggers
If you write methods in your Triggers, those can’t be exposed for test purposes. You also can’t expose logic to be re-used anywhere else in your Org.

3. Context-Specific Handler Methods
Create context-specific handler methods in Trigger handlers

4. Bulkify your Code
Bulkifying Apex code refers to the concept of making sure the code properly handles more than one record at a time.

5. Avoid SOQL Queries or DML statements inside FOR Loops
An individual Apex request gets a maximum of 100 SOQL queries before exceeding that governor limit. So if this trigger is invoked by a batch of more than 100 Account records, the governor limit will throw a runtime exception

6. Using Collections, Streamlining Queries, and Efficient For Loops
It is important to use Apex Collections to efficiently query data and store the data in memory. A combination of using collections and streamlining SOQL queries can substantially help writing efficient Apex code and avoid governor limits

7. Querying Large Data Sets
The total number of records that can be returned by SOQL queries in a request is 50,000. If returning a large set of queries causes you to exceed your heap limit, then a SOQL query for loop must be used instead. It can process multiple batches of records through the use of internal calls to query and query more

8. Use @future Appropriately
It is critical to writing your Apex code to efficiently handle bulk or many records at a time. This is also true for asynchronous Apex methods (those annotated with the @future keyword). The differences between synchronous and asynchronous Apex can be found

9. Avoid Hardcoding IDs When deploying Apex code between sandbox and production environments, or installing Force.com AppExchange packages, it is essential to avoid hardcoding IDs in the Apex code. By doing so, if the record IDs change between environments, the logic can dynamically identify the proper data to operate against and not fail.

19. In which sequence trigger and automation rules run in Salesforce.com?
The following is the order salesforce logic is applied to a record.

1. Old record loaded from database (or initialized for new inserts)
2. New record values overwrite old values
3. System Validation Rules
4. All Apex “before” triggers (EE / UE only)
5. Custom Validation Rules
6. Record saved to database (but not committed)
7. Record reloaded from database
8. All Apex “after” triggers (EE / UE only)
9. Assignment rules
10.Auto-response rules
11.Workflow rules
12.Escalation rules
13.Parent Rollup Summary Formula value updated (if present)
14.Database commit
15.Post-commit logic (sending email)

Additional notes: There is no way to control the order of execution within each group above.

20. what are the access modifiers in apex?
• Classes have different access levels depending on the keywords used in the class definition.
– global: this class is accessible by all Apex everywhere.
• All methods/variables with the web service keyword must be global.
• All methods/variables dealing with email services must be global.
• All methods/variables/inner classes that are global must be within a global class to be accessible.
– public: this class is visible across your application or namespace.
– private: this class is an inner class and is only accessible to the outer class, or is a test class.
• Top-Level (or outer) classes must have one of these keywords.
– There is no default access level for top-level classes.
– The default access level for inner classes is private.
– protected: this means that the method or variable is visible to any inner classes in the defining Apex class. You can only use this access modifier for instance methods and member variables.

21. In How Many Ways We Can Invoke The Apex Class?
1. Visualforce page
2. Trigger
3. Web Services
4. Email Services
5. Process Builder

22. What is the difference between with sharing and without sharing?
With sharing Keyword: This keyword enforces sharing rules that apply to the current user. If absent, code is run under default system context. Use the with sharing keywords when declaring a class to enforce the sharing rules that apply to the current user. Use With Sharing when the User has access to the records being updated via Role, Sharing Rules, Sales Teams – any sort of sharing really.

Example:

public with sharing class sharingClass {

// Code here

}

Without sharing keyword: Ensures that the sharing rules of the current user are not enforced. Use the without sharing keywords when declaring a class to ensure that the sharing rules for the current user are not enforced. For example, you may want to explicitly turn off sharing rule enforcement when a class acquires sharing rules when it is called from another class that is declared using with sharing. Without Sharing is reserved for cases where the User does not have access to the records, but there is a need to update them based on user input.

public without sharing class noSharing {

// Code here

}

Some things to note about sharing keywords:

The sharing setting of the class where the method is defined is applied, not of the class where the method is called. For example, if a method is defined in a class declared with with sharing is called by a class declared with without sharing, the method will execute with sharing rules enforced. If a class isn’t declared as either with or without sharing, the current sharing rules remain in effect. This means that the class doesn’t enforce sharing rules except if it acquires sharing rules from another class. For example, if the class is called by another class that has sharing enforced, then sharing is enforced for the called class. Both inner classes and outer classes can be declared as with sharing. The sharing setting applies to all code contained in the class, including initialization code, constructors, and methods. Inner classes do not inherit the sharing setting from their container class. Classes inherit this setting from a parent class when one class extends or implements another.

23. What are setter and getter methods?
Getter and Setter methods in salesforce are used to pass data from controller to visualforce and vice versa.

setter method value will be passed from visualforce page to controller ( Apex class) and same can be retrieved back to visualforce page through controller getter method.

24. How do you reffer to current page id in apex?
apexpages.currentpage().getparameters().get('id')

25. What is difference between WhoId and WhatId in the Data Model of Task ?
WhoID refers to people things. i.e. Lead ID or a Contact ID.

WhatID refers to object type things. i.e. Account ID or an Opportunity ID so on.

26. What Is The Difference Between Soql And Sosl?
SOQL ( Salesforce Object Query Language)
Only one object at a time can be searched
Query all type of fields
It can be used in triggers and classes
DML operation can be performed on query results

SOSL (Salesforce Object Search Language)
Many objects can be searched at a time
Query only e-mail, phone and text
It can be used in classes but not in triggers
DML operation cannot be performed on search result

27. I have 1 parent(account) and 1 child(contact),how will you get First Name,Last Name from child and email from the parent when Organization name in account is “CTS”?
SELECT Email, (SELECT FirstName, LastName FROM Contacts) FROM account WHERE Organization_Name = ‘CTS’.

28. Explain Difference In Count() And Count(fieldname) In Soql.?
COUNT()

COUNT() must be the only element in the SELECT list.
You can use COUNT() with a LIMIT clause.
You can’t use COUNT() with an ORDER BY clause. Use COUNT(fieldName) instead.
You can’t use COUNT() with a GROUP BY clause for API version 19.0 and later. Use COUNT(fieldName) instead.

COUNT(fieldName)

You can use COUNT(fieldName) with an ORDER BY clause.
You can use COUNT(fieldName) with a GROUP BY clause for API version 19.0 and later.

29. Which SOQL statement can be used to get all records even from recycle bin or Achieved Activities?
We will need “ALL Rows” clause of SOQL.
SELECT COUNT() FROM Contact WHERE AccountId = a.Id ALL ROWS

30. How can you lock record using SOQL so it cannot be modified by other user?
we will need “FOR UPDATE” clause of SOQL.
Account [] accts = [SELECT Id FROM Account LIMIT 2 FOR UPDATE];

31. Difference between insert/update and Database.insert/ Database.update?
insert/update
Assume that you are inserting 100 records. If any one of the record fail due to error then entire operation will fail. None of the records will be saved into the database.

Database.insert/Database.update
Assume that you are inserting 100 records. If any one of the record fail due to error then it will perform partial operation (valid records will be inserted/updated) if we use Database.insert(list,false)/ Database.update(list,false).

32. What are the aggregate functions supported by salesforce SOQL?
Following aggregate functions are supported by salesforce SOQL
1. SUM()
2. MIN()
3. MAX()
4. COUNT()
5. AVG()
6. COUNT_DISTINCT()

33. Write a sample aggregate query or explain how to write a aggregate queries?
The return types of Aggregate functions are always an array of AggregateResult.

Sample Code

AggregateResult[] ar = [select AVG(Amount) aver from Opportunity];
Object avgAmt = ar[0].get(‘aver’);

34. Some known governor limits in salesforce.com?
Total number of SOQL queries issued: 100
Total number of records retrieved by SOQL queries; 50,000
Total number of records retrieved by Database.getQueryLocator: 10,000
Total number of SOSL queries issued: 20
Total number of records retrieved by a single SOSL query: 2,000
Total number of DML statements issued: 150
Total number of records processed as a result of DML statements, Approval.process, or database.emptyRecycleBin: 10,000
Total stack depth for any Apex invocation that recursively fires triggers due to insert, update, or delete statements: 16
Total number of callouts (HTTP requests or Web services calls) in a transaction: 100
Maximum cumulative timeout for all callouts (HTTP requests or Web services calls) in a transaction: 120 seconds
Maximum number of methods with the future annotation allowed per Apex invocation: 50
Maximum number of Apex jobs added to the queue with System.enqueueJob: 50
Total number of sendEmail methods allowed: 10
Total heap size: 6 MB
Maximum CPU time on the Salesforce servers: 10,000 milliseconds
Maximum execution time for each Apex transaction: 10 minutes
Maximum number of push notification method calls allowed per Apex transaction: 10
Maximum number of push notifications that can be sent in each push notification method call: 2,000


35. Can we create 2 opportunities while the Lead conversion ?
Yes using Apex code.

36. Other than Soql and Sosl what is other way to get custom Settings?
Other than SOQL or SOSL, Custom settings have their own set of methods to access the record.

For example:If there is custom setting of name ISO_Country,

SO_Country__c code = ISO_Country__c.getInstance(‘INDIA’);

//To return a map of data sets defined for the custom object (all records in the custom object), //you would use:

Map mapCodes = ISO_Country__c.getAll();

// display the ISO code for India

System.debug(‘ISO Code: ‘+mapCodes.get(‘INDIA’).ISO_Code__c);

//Alternatively you can return the map as a list:

List listCodes = ISO_Country__c.getAll().values();

37. How to get all the fields of Sobject using dynamic apex?
Map m = Schema.getGlobalDescribe() ;

Schema.SObjectType s = m.get('API_Name_Of_SObject') ;

Schema.DescribeSObjectResult r = s.getDescribe() ;

Map fields = r.fields.getMap();

38. What Are Global Variables Explain With Examples?
Global variables are the variables used to reference the general information about the current user or your organization on a page.

Example:

Global variables must be referenced using Visualforce expression syntax to be evaluated, for example, {!$User.Name}.

List of available global variables are as below:

1. $Action
2. $Api
3. $Component
4. $ComponentLabel
5. $CurrentPage
6. $Label
7. $Label.Site
8. $ObjectType
9. $Organization
10. $Page
11. $Profile
12. $Resource
13. $SControl
14. $Setup
15. $Site
16. $User
17. $UserRole
18. $System.OriginDateTime
19. $ User.UITheme and $User.UIThemeDisplayed

39. What is Wrapper Class?
A Wrapper class is a class whose instances are collection of other objects.

It is used to display different objects on a Visual Force page in same table.

40. What are the effects of using the transient keyword?
The transient key word prevents the data from being saved into the view state. This should be used for very temporary variables.

41. Can you please give some information about Implicit and Explicit Invocation of apex?
Triggers - Implicit
Javascript remoting - Explicit

42. Can you give me situation where we can use workflow rather than trigger?
As i mention in question number 2 salesforce best practice is, if something can be done using Configurations (Declarative) then its preferred over coding.

If any thing we need to perform in same object we should go for a workflow rule and in case of master detail relationship we also update child to parent.

43. What is difference between public and global class in Apex ?
Public class can be accessed within application or namespace. This is not exactly like public modifier in Java.
Global class visible everywhere, any application or namespace. WebService must be declared as Global and which can be accessed inside Javascript also. It is like public modifier in Java.

44. Explain Considerations for Static keyword in Apex?
Apex classes cannot be static.
Static allowed only in outer class.
Static variables not transferred as a part of View State.
Static variables and static block runs in order in which they are written in class.
Static variables are static only in scope of request.

45. What is the use of save point in java script?
This will use for the rollback changes.

46. How many types of email services in salesforce? Write a apex code to send a email?
Their are two types of email services in salesforce

1. Inbound Email Services.
2. Outbound Email Services.

Sample code snippet to send an email using apex code

Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
String[] toAddresses = new String[]{‘talk2srikrishna@gmail.com’};
mail.setToAddress(toAddresses);
mail.setSubject(‘Sample Mail Subject’);
mail.setPlainTextBody(‘Hello World!’);
Messaging.sendEmail(new Messaging.SingleEmailMessage[]{mail});

47. How can we hard delete a record using a Apex class/by code?
ALL ROWS keyword can be used to get all the records including records in the recycle bin.
Below is the sample code to delete contact records from recycle bin

List dContactList=[Select ID From Contact Where IsDeleted = true limit 199 ALL ROWS];
Database.emptyRecycleBin( dContactList );

48. What is the purpose of writing the test class?
After developing an apex class or apex trigger we should write the unit tests and ensure that we are able to execute at least 75% of the lines of code.

If you are moving the code from sandbox to sandbox regarding code coverage you won't face any issue.

If you are moving the code from sandbox to production, you need to include all the test classes at the time of deployment and salesforce will run all the test classes which you included for the deployment as well as test classes which are already present in production, if the code coverage is less than 75% deployment will fail.

49. Syntax of testMethod?
@isTest
private class MyTestClass {

static testMethod void myTest1() {
}

static testMethod void myTest2() {
}

}

50. What is the purpose of seeAllData?
By default test class cannot recognize the existing data in the database.

if you mention @isTest(seeAllData = true) then test class can recognize the existing data in the database.

See the below examples -

From a List Custom Settings we cannot fetch the existing data without seeAllData = true in test class.
Suppose you have a custom object called 'CustomObject__c' and it contains many records, we cannot fetch the existing data without seeAllData = true in test class.
Note: It is not recommended to use seeAllData = true for a test class. Based on the existing data in database code coverage will impact.

51. What is the purpose of Test.startTest() and Test.stopTest()?
Test.startTest() and Test.stopTest() maintains fresh set of governor limits. Assume that you are consuming 99 SOQL queries outside of Test.startTest() and Test.stopTest() then if you include any SOQL inside of Test.startTest() and Test.stopTest() count will start from 1.

Per testMethod we can use Test.startTest() and Test.stopTest() only for one time.

To execute asynchronous methods synchronously we can call those methods from inside of Test.startTest() and Test.stopTest().

52. What is the purpose of system.runAs()?
By default test class runs in System Mode. If you want to execute a piece of code in a certain user context then we can use system.runAs(UserInstance). For more details refer 2nd question in visualforce category.

To avoid MIXED-DML-OPERATION error we can include DML statements inside of system.runAs(), still the error persists keep DML statements inside of Test.startTest() and Test.stopTest().

53. What are the assert statements?
To compare Actual value and Expected value we use assert statements.

Types of assert statements

system.assertEquals(val1,val2): If both val1 and val2 are same then test class run successfully otherwise test class will fail.
system.assertNotEquals(val1,val2): If both val1 and val2 are not same then test class run successfully otherwise test class will fail.
system.assertEquals(val1> val2): If the condition satisfied then test class run successfully otherwise test class will fail.

54. What is the purpose of Test.isRunningTest()?
Sometimes we cannot satisfy certain if conditions for the apex classes, in those situations on those if conditions we can add Test.isRunningTest separated with or condition. Example: if(condition || Test.isRunningTest())

55. What is the purpose of @TestVisible?
Sometimes in test classes, we need to access a variable from Apex Class, if it is private we cannot access for that we will replace private with public. for this reason, we are compromising the security. To avoid this before the private variables in apex class we can include @TestVisible so that even though the variable is private we can access the test class.

56. What is the test class best practice?
1. Test class must start with @isTest annotation if class version is more than 25.
2. Test environment support @testVisible, @testSetUp as well.
3. Unit test is to test particular piece of code working properly or not.
4. Unit test method takes no argument, commit no data to database, send no email, flagged with testMethod keyword.
5. To deploy to production at-least 75% code coverage is required.
6. System.debug statement are not counted as a part of apex code limit.
7. Test method and test classes are not counted as a part of code limit.
9. We should not focus on the percentage of code coverage, we should make sure that every use case should be covered including positive, negative, bulk and single record. Single Action -To verify that the single record produces the correct an expected result. Bulk action -Any apex record trigger, class or extension must be invoked for 1-200 records. Positive behavior: Test every expected behavior occurs through every expected permutation, I,e user filled out every correct data and not go past the limit. Negative Testcase: -Not to add future date, Not to specify the negative amount. Restricted User: -Test whether a user with restricted access used in your code. 10. Test class should be annotated with @isTest.
11 . @isTest annotation with test method is equivalent to testMethod keyword.
12. Test method should static and no void return type.
13. Test class and method default access is private , no matter to add access specifier.
14. classes with @isTest annotation can't be an interface or enum.
15. Test method code can't be invoked by non-test request.
16. Stating with Salesforce API 28.0 test method cannot reside inside nontest classes.
17. @Testvisible annotation to make visible private methods inside test classes.
18. The test method cannot be used to test web-service call out. Please use callout mock.
19. You can't send email from test method.
20.User, profile, organization, AsyncApexjob, Corntrigger, RecordType, ApexClass, ApexComponent ,ApexPage we can access without (seeAllData=true).
21. SeeAllData=true will not work for API 23 version earlier.
22. Accessing static resource test records in test class e,g List accList=Test.loadData(Account,SobjectType,resource name').
23. Create TestFactory class with @isTest annotation to exclude from organization code size limit.
24. @testSetup to create test records once in a method and use in every test method in the test class.
25. We can run unit test by using Salesforce Standard UI,Force.com IDE , Console , API.
26. Maximum number of test classes run per 24 hours of period is not greater of 500 or 10 multiplication of test classes of your organization.
27. As apex runs in system mode so the permission and record sharing is not taken into account. So we need to use a system.runAs to enforce record sharing.
28. System.runAs will not enforce user permission or field level permission.
29. Every test to runAs count against the total number of DML issued in the process.

57. What is Asynchronous Apex?
In a nutshell, asynchronous Apex is used to run processes in a separate thread, at a later time.

An asynchronous process is a process or function that executes a task "in the background" without the user having to wait for the task to finish.

Here’s a real-world example. Let’s say you have a list of things to accomplish before your weekly Dance Dance Revolution practice. Your car is making a funny noise, you need a different color hair gel and you have to pick up your uniform from your mom’s house. You could take your car to the mechanic and wait until it is fixed before completing the rest of your list (synchronous processing), or you could leave it there and get your other things done, and have the shop call you when it’s fixed (asynchronous processing). If you want to be home in time to iron your spandex before practice, asynchronous processing allows you to get more stuff done in the same amount of time without the needless waiting.

58. What is batch apex?
Batch Apex is used to run large jobs (think thousands or millions of records!) that would exceed normal processing limits. Using Batch Apex, you can process records asynchronously in batches (hence the name, “Batch Apex”) to stay within platform limits. If you have a lot of records to process, for example, data cleansing or archiving, Batch Apex is probably your best solution.

59. Write a syntax and structure of batch class?
Sample class

global class MyBatchClass implements Database.Batchable {

global (Database.QueryLocator | Iterable) start(Database.BatchableContext bc) {
// collect the batches of records or objects to be passed to execute
}

global void execute(Database.BatchableContext bc, List

records){
// process each batch of records
}

global void finish(Database.BatchableContext bc){
// execute any post-processing operations
}

}

Below code will call the batch class

BatchDemo bd = new BatchDemo();
database.executebatch(bd);

60. Suppose we have a batch size of 20 and we have 50 records so how many times each methods calls in batch class ?
Start method call at once.
Execute method call at three time.
Finish method call at once

61. Is it possible to call batch class from one more batch class?
Yes, it is possible, starting with Apex saved using Salesforce API version 26.0, you can call Database.executeBatch or System.scheduleBatch from the finish method. This enables you to start or schedule a new batch job when the current batch job finishes.

For previous versions, you can’t call Database.executeBatch or System.scheduleBatch from any batch Apex method. Note that the version used is the version of the running batch class that starts or schedules another batch job. If the finish method in the running batch class calls a method in a helper class to start the batch job, the Salesforce API version of the helper class doesn’t matter.

62. Is it possible to call future method from a batch class?
We cannot call one asynchronous process from another asynchronous process.

Since @future method and Batch Class both are asynchronous we cannot call a future method from the batch class or we cannot call a batch class from the future method.

63. How many batch jobs can be active/queued at a time?
Up to 5 batch jobs can be queued or active.

64. Is it possbile to write batch class and schedulable class in a same class?
By implementing Database.Batchable and Schedulable interfaces we can implement the methods in a same class.

Though it is possible it is not recommended to write like this.

65. What is Future method?
Future method is used to run processes in a separate thread, at a later time when system resources become available.

66. What is future method syntax? And some use cases of future methods?
global class SomeClass {
@future
public static void someFutureMethod(List recordIds) {
List accounts = [Select Id, Name from Account Where Id IN :recordIds];
// process account records to do awesome stuff
}
}

Callouts to external Web services. If you are making callouts from a trigger or after performing a DML operation, you must use a future or queueable method. A callout in a trigger would hold the database connection open for the lifetime of the callout and that is a "no-no" in a multitenant environment.
Operations you want to run in their own thread when time permits such as some sort of resource-intensive calculation or processing of records.
Isolating DML operations on different sObject types to prevent the mixed DML error. This is somewhat of an edge-case but you may occasionally run across this issue. See sObjects That Cannot Be Used Together in DML Operations for more details.

67. Explain few considerations for @Future annotation in Apex?
Method must be static
Cannot return anything ( Only Void )
To test @future methods, you should use startTest and stopTest to make it synchromouse inside Test class.
Parameter to @future method can only be primitive or collection of primitive data type.
Cannot be used inside VF in Constructor, Set or Get methods.
@future method cannot call other @future method.

68. In an apex invocation how many methods that we can write as future annotations?
10

69. What is Queueable Class?
Released in Winter '15, Queueable Apex is essentially a superset of future methods with some extra #awesomesauce. We took the simplicity of future methods and the power of Batch Apex and mixed them together to form Queueable Apex! It gives you a class structure that the platform serializes for you, a simplified interface without start and finish methods and even allows you to utilize more than just primitive arguments! It is called by a simple System.enqueueJob() method, which returns a job ID that you can monitor. It beats sliced bread hands down!

70. What is Queueable Class Syntax? And some additional benefits over future methods?
public class SomeClass implements Queueable {
public void execute(QueueableContext context) {
// awesome code here
}
}

Non-primitive types: Your Queueable class can contain member variables of non-primitive data types, such as sObjects or custom Apex types. Those objects can be accessed when the job executes.
Monitoring: When you submit your job by invoking the System.enqueueJob method, the method returns the ID of the AsyncApexJob record. You can use this ID to identify your job and monitor its progress, either through the Salesforce user interface in the Apex Jobs page or programmatically by querying your record from AsyncApexJob.
Chaining jobs: You can chain one job to another job by starting a second job from a running job. Chaining jobs are useful if you need to do some sequential processing.

71. What is Scheduled Class? And syntax of Scheduled Class?
The Apex Scheduler lets you delay execution so that you can run Apex classes at a specified time. This is ideal for daily or weekly maintenance tasks using Batch Apex.

global class SomeClass implements Schedulable {
global void execute(SchedulableContext ctx) {
// awesome code here
}
}

The class implements the Schedulable interface and must implement the only method that this interface contains, which is the execute method.

72. What are different API in Salesforce.com?
REST API:
REST API provides a powerful, convenient, and simple REST-based Web services interface for interacting with Salesforce. Its advantages include ease of integration and development, and it’s an excellent choice of technology for use with mobile applications and Web projects. However, if you have a large number of records to process, you may wish to use Bulk API, which is based on REST principles and optimized for large sets of data.

SOAP API:
SOAP API provides a powerful, convenient, and simple SOAP-based Web services interface for interacting with Salesforce.You can use SOAP API to create, retrieve, update, or delete records. You can also use SOAP API to perform searches and much more. Use SOAP API in any language that supports Web services.
For example, you can use SOAP API to integrate Salesforce with your organization’s ERP and finance systems, deliver real-time sales and support information to company portals, and populate critical business systems with customer information.

Chatter API:
Chatter API is a REST API that provides programmatic access to Chatter feeds and social data such as users, groups, followers, and files. It's used by developers who want to integrate Chatter into a variety of applications such as mobile applications, intranet sites, and third-party Web applications. Chatter API is similar to APIs offered by other companies with feeds, such as Facebook and Twitter. Its advantages include ease of integration and development.

Bulk API:
Bulk API is based on REST principles and is optimized for loading or deleting large sets of data. You can use it to query, insert, update, upsert, or delete a large number of records asynchronously by submitting batches which are processed in the background by Salesforce.
SOAP API, in contrast, is optimized for real-time client applications that update small numbers of records at a time. Although SOAP API can also be used for processing large numbers of records, when the data sets contain hundreds of thousands of records, it becomes less practical. Bulk API is designed to make it simple to process data from a few thousand to millions of records.
The easiest way to use Bulk API is to enable it for processing records in Data Loader using CSV files. This avoids the need to write your own client application.

Metadata API:
Use Metadata API to retrieve, deploy, create, update, or delete customizations for your organization. The most common use is to migrate changes from a sandbox or testing organization to your production environment. Metadata API is intended for managing customizations and for building tools that can manage the metadata model, not the data itself.
The easiest way to access the functionality in Metadata API is to use the Force.com IDE or Force.com Migration Tool. These tools are built on top of Metadata API and use the standard Eclipse and Ant tools respectively to simplify the task of working with Metadata API. Built on the Eclipse platform, the Force.com IDE provides a comfortable environment for programmers familiar with integrated development environments, allowing you to code, compile, test, and deploy all from within the IDE itself. The Force.com Migration Tool is ideal if you want to use a script or a command-line utility for moving metadata between a local directory and a Salesforce organization.

Streaming API:
Use Streaming API to receive notifications for changes to data that match a SOQL query that you define.
Streaming API is useful when you want notifications to be pushed from the server to the client. Consider Streaming API for applications that poll frequently. Applications that have constant polling action against the Salesforce infrastructure, consuming unnecessary API call and processing time, would benefit from this API which reduces the number of requests that return no data. Streaming API is also ideal for applications that require general notification of data changes. This enables you to reduce the number of API calls and improve performance.

Apex REST API:
Use Apex REST API when you want to expose your Apex classes and methods so that external applications can access your code through REST architecture. Apex REST API supports both OAuth 2.0 and Session ID for authorization.

Apex SOAP API:
Use Apex SOAP API when you want to expose your Apex methods as SOAP Web service APIs so that external applications can access your code through SOAP. Apex SOAP API supports both OAuth 2.0 and Session ID for authorization.

Monday, 9 October 2017

Salesforce.com Admin Interview Questions



1. What is Cloud Computing?
Cloud computing is a general term for the delivery of hosted services over the internet.

i.e.: You are probably using cloud computing right now, even if you don’t realize it. If you use an online service to send email, edit documents, watch movies or TV, listen to music, play games or store pictures and other files, it is likely that cloud computing is making it all possible behind the scenes.

2. What are Saas, Paas, and Iaas?
SaaS (Software as a Service) model you are provided with access to application software often referred to as "on-demand software". You don't have to worry about the installation, setup, and running of the application. The service provider will do that for you. You just have to pay and use it for some client. Examples: Salesforce.com, Google Apps, Microsoft Office 365.

PaaS (Platform as a Service), as the name suggests, provides you computing platforms which typically includes an operating system, programming language execution environment, database, web server etc. Examples: AWS Elastic Beanstalk, Windows Azure, Heroku, Force.com, Google App Engine, Apache Stratos.

IaaS (Infrastructure as a Service), as the name suggests, provides you the computing infrastructure, physical or (quite often) virtual machines and other resources like virtual-machine disk image library, block and file-based storage, firewalls, load balancers, IP addresses, virtual local area networks etc. Examples: Amazon EC2, Windows Azure, Rackspace, Google Compute Engine.

3. What are the Advantages of Cloud Computing?
Cost Savings: Perhaps, the most significant cloud computing benefit is in terms of IT cost savings. Businesses, no matter what their type or size, exist to earn money while keeping capital and operational expenses to a minimum. With cloud computing, you can save substantial capital costs with zero in-house server storage and application requirements. The lack of on-premises infrastructure also removes their associated operational costs in the form of power, air conditioning, and administration costs. You pay for what is used and disengage whenever you like - there is no invested IT capital to worry about. It’s a common misconception that only large businesses can afford to use the cloud, when in fact, cloud services are extremely affordable for smaller businesses.

Reliability: With a managed service platform, cloud computing is much more reliable and consistent than in-house IT infrastructure. Most providers offer a Service Level Agreement which guarantees 24/7/365 and 99.99% availability. Your organization can benefit from a massive pool of redundant IT resources, as well as quick failover mechanism - if a server fails, hosted applications and services can easily be transited to any of the available servers.

Manageability: Cloud computing provides enhanced and simplified IT management and maintenance capabilities through central administration of resources, vendor managed infrastructure and SLA backed agreements. IT infrastructure updates and maintenance are eliminated, as all resources are maintained by the service provider. You enjoy a simple web-based user interface for accessing software, applications, and services – without the need for installation - and an SLA ensures the timely and guaranteed delivery, management and maintenance of your IT services.

Strategic Edge: Ever-increasing computing resources give you a competitive edge over competitors, as the time you require for IT procurement is virtually nil. Your company can deploy mission-critical applications that deliver significant business benefits, without any upfront costs and minimal provisioning time. Cloud computing allows you to forget about technology and focus on your key business activities and objectives. It can also help you to reduce the time needed to market newer applications and services.

4. What is CRM?
CRM = Customer Relationship Management A CRM system is a business tool that allows you to manage all your customers, partners and prospects information all in one place. The Sales Cloud (Salesforce.com’s CRM system) is a secure cloud based CRM system that can help every part of your business get a 360 degree view of your customer.

For example, it helps: sales teams close deals faster marketing manage campaigns and track lead generation service call centres reduce the time to resolve customer complaints

5. What is Salesforce?
Salesforce is the world’s #1 Customer Relationship Management (CRM) platform. Our cloud-based applications for sales, service, marketing,analytics,App,IOT and more don’t require System expert or advanced infrastructure to handle it's based on Saas-simply log in and start connecting to customers in a whole new way.

6. What is the diffrence between Salesforce.com and force.com?
Salesforce.com = Company and the pre-built applications offered by the company, most notably the CRM software it is basically software-as-a-service (SaaS).

Force.com = Platform-as-a-Service (PaaS) offering from the same company that allows you to build your own applications and/or customize the standard applications.

7. What is out of box functionality in Salesforce?
Out of the box, functionality means the standard capabilities that are available in a Salesforce.com. i.e. Salesforce provides a lot of features that are available for the users to use directly without making any changes. This, of course, varies by the edition of Salesforce. i.e. there are features like Standard Reports, Standard dashboards, page layouts, standard objects and standard fields, administrative features etc. which can be directly used without any modification.

8. Explain what is custom objects in salesforce?
Custom objects are objects that you create to store information that’s specific to your company or industry. For DreamHouse, D’Angelo wants to build a custom Property object that stores information about the homes his company is selling.

9. How can you define Field Dependency?
Field dependency means controlling a fields value based on the other field value. For Example: thier are two fields called country and state. I want to display only state related to specific selected country when i select country.

10. How many custom fields can I created in an object?
It's based on the salesforce edition
Professional Edition: 100
Enterprise Edition: 500
Developer Edition: 500
Unlimited and Performance Edition: 800

11. What is sales cloud in salesforce?
"Sales Cloud" refers to the "sales" module in salesforce.com. It includes Leads, Accounts, Contacts, Contracts, Opportunities, Products, Price books, Quotes, and Campaigns (limits apply). It includes features such as Web-to-lead to support online lead capture, with auto-response rules.

12. What is service cloud in salesforce?
Salesforce Service Cloud is a customer relationship management (CRM) platform for customer service and support, based on the company's CRM software for sales professionals.

13. What is analytics cloud in salesforce?
Salesforce Wave Analytics, also called Analytics Cloud, is a business intelligence (BI) platform from Salesforce.com that is optimized for mobile access and data visualization.

14. What is marketing cloud in salesforce?
Salesforce Marketing Cloud is a customer relationship management (CRM) platform for marketers that allows them to create and manage marketing relationships and campaigns with customers.

15. Describe Sales process in Salesforce?
The Sales Process. Every company is unique, but all companies want to find, sell to, and keep customers. Salesforce has the tools you need to grow your pipeline and make more sales. Salesforce features designed to support your sales process include leads, campaigns, products, pricebooks, opportunities, and quotes.

For more information

16. What is Multitenant environment?
Multitenancy is the fundamental technology that clouds use to share IT resources cost-efficiently and securely. Just like a bank—in which many tenants cost-efficiently share a hidden, common infrastructure, yet utilize a defined set of highly secure services, with complete privacy from other tenants—a cloud uses multitenancy technology to share IT resources securely among multiple applications and tenants (businesses, organizations, etc.) that use the cloud. Some clouds use virtualization-based architectures to isolate tenants; others use custom software architectures to get the job done.

17. What is Validation rule?
Validation rules verify that the data a user enters in a record meets the standards you specify before the user can save the record. A validation rule can contain a formula or expression that evaluates the data in one or more fields and returns a value of “True” or “False”. Validation rules also include an error message to display to the user when the rule returns a value of “True” due to an invalid value.

18. What are Governor limits?
Since salesforce runs in multitenant environment and order to have some performance to the database, it has imposed some run time limits called governor limits.
There are many types of governor limits like pre transaction limits, force.com platform apex limits, static apex limits and many other limits.

For more information

19. What is a queue?
Queues help your teams to manage service contracts, cases, leads and custom objects. Once records are placed in a queue manually or through an automatic case or lead assignment rule, records remain there until they're assigned to a user or taken by one of the queue members.

Example for: you have a team of Sales Users who will work on Leads. You might get a lot of leads from an integration, and not have time to manually assign each one to a specific Sales User. In this very common case, you'd simply assign the leads to a Queue, then add your Sales Reps as Queue Members so they can pick and choose the leads they want from this Queue.

20. What is a group?
A group consists of a set of users. A group can contain individual users, other groups, or the users in a particular role or territory. It can also contain the users in a particular role or territory plus all the users below that role or territory in the hierarchy.
Available in: both Salesforce Classic and Lightning Experience
Available in: Professional, Enterprise, Performance, Unlimited, Developer, and Database.com Editions
There are two types of groups.
Public groups
Administrators and delegated administrators can create public groups. Everyone in the organization can use public groups. For example, an administrator can create a group for an employee carpool program. All employees can then use this group to share records about the program.
Personal groups
Each user can create groups for their personal use. For example, users might need to ensure that certain records are always shared within a specified workgroup.

21. What is auto-response rule?
Auto response rule is a set of conditions for sending automatic email responses to lead or case submissions based on the attributes of the submitted record. Applicable leads include those captured through a Web-to-Lead form.

22. What is assignment rules?
Create assignment rules to automate your organization's lead generation and support processes. Lead Assignment Rules—Specify how leads are assigned to users or queues as they are created manually, captured from the web, or imported via the Data Import Wizard.

23. At the same time can we activate two assignment rule?
At a time only one assignment rule can be active for an Org.

24. What is escalation rule?
Case escalation rules are used to reassign and optionally notify individuals when a case is not closed within a specified time period.

25. What is service console?
Service Cloud Console is a Salesforce application that is designed for users in a fast-paced environment that need to find, update, and create records quickly. SCC introduces a tabbed environment in which users are able to look at different groupings of records in one screen via a Secondary and Primary tab.

26. What are web-to-lead and web-to-case?
A web-to-lead form is an essential component of marketing and sales automation. Its purpose is to capture data submitted by website visitors, such as contact information and product interest, and store it as a “Lead” record in a CRM product, in this case Salesforce.com.

This can help your organization respond to customers faster, improving your support team's productivity. ▪ Web To Case is a means by which you can post a simple, unauthenticated web page that allows your customers. to submit cases directly to your Salesforce.com instance.

27. What is a relationship in Salesforce?
Object Relationships in Salesforce. A relationship is a bi-directional association between two objects. Relationships allows us to create links between one object and another.

28. How many types of relationship in salesforce?
Master-detail relationship
Lookup relationship
Self-relationship
External lookup relationship
Indirect lookup relationship
Many-to-many relationship (junction object)
Hierarchical relationship

29. What is the difference between Lookup and Master-detail relationship?
Master – Detail Relationship :
(1) If we delete master records then detail (Child) records are deleted. (2) It creates the parent(master) child(Detail) relationship between objects. (3) Child records do not have Owner fields it takes parents records owner as child records owner. (4) We can have maximum 2 master details on an object

Look up relationship :
(1) Look up relationship creates relations between two objects. (2) If we delete any object then other object is not deleted. (3) We can have maximum 25 lookup on an object.

30. List out the characteristics and functions of Roll-up summary field?
A roll-up summary field calculates values from related records, such as those in a related list. You can create a roll-up summary field to display a value in a master record based on the values of fields in a detail record. The detail record must be related to the master through a master-detail relationship. For example, you want to display the sum of invoice amounts for all related invoice custom object records in an account’s Invoices related list. You can display this total in a custom account field called Total Invoice Amount.

31. Can we have Roll up Summary fields in case of Parent-Child Relationships?
Roll-Up summary fields are a great way to perform calculations on a set of detail records in a master-detail relationship. For instance, if you have a sales order you can create a roll-up summary field to display the sum total of all sales order items (related detail records) for the sales order. The one drawback regarding roll-up summary fields is that they only work for master-details relationships. If you have a lookup relationship to your detail records from your sales order, then roll-up summary fields are not available.

32. Can we convert the look up relationship to Master Detail relationship? If so How can we convert?
Yes we can. Create the look up relationship and populate that field in all the records. After that you can convert the look up to master detail. This is because the master detail field is basically mandatory on the child record. So unless you specify values in all the records , you wont be allowed to convert the look up to masterdetail.

33. Can we create Master Detail relationship on existing records?
We can't create a master-detail relationship if the custom object already contains data. You can, however, create the relationship as a lookup and then convert it to master-detail if the lookup field in all records contains a value.

34. In case of Master-Detail relationship, on Update of master record can we update the field of child record using workflow rule?
Currently workflows dont support this. You can only update child to parent in case of master-detail relationship.

35. In case of Master-Detail relationship, on Update of child record can we update the field of Parent record using workflow rule?
Yes, we can update the field of Parent record using workflow rule.

36. What happens to detail record when master record is deleted?
When master Record is deleted, it’s detail records are also deleted.

37. What is Junction object in Salesforce?
In salesforce, Junction Object are the part of the objects which joins one object to another. These are specially used to join many objects in Many to Many relationships.

38. Tell me the name of two standard junction object in Salesforce?
1. OpportunityLineItem
2. PriceBookEntry

39. What is Profile?Name some Standard profile available in Salesforce?
A profile is a group/collection of settings and permissions that define what a user can do in salesforce. A profile controls “Object permissions, Field permissions, User permissions, Tab settings, App settings, Apex class access, Visualforce page access, Page layouts, Record Types, Login hours & Login IP ranges.

(1) System Administrator
(2) Standard User
(3) Marketing User
(4) Read Only
(5) Chatter Free User

40. Two users can have the same profile in Salesforce?
Yes

41. One users can have the two role in Salesforce?
No

42. What is Permission set?
A permission set is a collection of settings and permissions that give users access to various tools and functions. The settings and permissions in permission sets are also found in profiles, but permission sets extend users’ functional access without changing their profiles.

Always remember permision set only extend the permision it's not restrict any user.

43. What is Owd?
OWD is the default access level on records for any object in the sales force, This is baseline security.
For custom objects, we can see below access levels -
Private
Public Read-only
Public Read/Write
By default after creating custom object OWD access level is Public Read/Write.

Private: only owner and above hierarchy users can have Read/Write access and below hierarchy users don't have any access.
Public Read-only: only owner and above hierarchy users can have Read/Write access and below hierarchy users can have only Read-Only access.
Public Read/Write: Irrespective of role hierarchy every one can have Read/Write permissions on the records.

44. What is role?
Role control record level access can be controlled by Role. Depending on your sharing settings, roles can control the level of visibility that users have into your organization’s data. Users at any given role level can view, edit, and report on all data owned by or shared with users below them in the hierarchy, unless your organization’s sharing model for an object specifies otherwise.

45. What is sharing rule?
Sharing rules give you additional record access beyong the original OWD.
You can assign sharing rules to groups, Roles, Manager Roles, etc.
You can expand the access to Read Only or Read/Write.

46. Can we use sharing rules to restrict data access?
Sharing rules are for opening access to the records not for restricting.

47. What are the different types of Sharing Rules in Salesforce and explain them?
Force.com Managed Sharing:-
Force.com managed sharing involves sharing access granted by Force.com based on record ownership, the role hierarchy, and sharing rules:

Record Ownership:-
Each record is owned by a user or optionally a queue for custom objects, cases, and leads. The record owner is automatically granted Full Access, allowing them to view, edit, transfer, share, and delete the record.

Role Hierarchy:-
The role hierarchy enables users above another user in the hierarchy to have the same level of access to records owned by or shared with users below. Consequently, users above a record owner in the role hierarchy are also implicitly granted Full Access to the record, though this behavior can be disabled for specific custom objects. The role hierarchy is not maintained with sharing records. Instead, role hierarchy access is derived at runtime. For more information, see “Controlling Access Using Hierarchies” in the Salesforce online help.

Sharing Rules:-
Sharing rules are used by administrators to automatically grant users within a given group or role access to records owned by a specific group of users. Sharing rules cannot be added to a package and cannot be used to support sharing logic for apps installed from Force.com AppExchange.
Sharing rules can be based on record ownership or other criteria. You can’t use Apex to create criteria-based sharing rules. Also, criteria-based sharing cannot be tested using Apex.
All implicit sharing added by Force.com managed sharing cannot be altered directly using the Salesforce user interface, SOAP API, or Apex.
User-Managed Sharing, also known as Manual Sharing
User managed sharing allows the record owner or any user with Full Access to a record to share the record with a user or group of users. This is generally done by an end-user, for a single record. Only the record owner and users above the owner in the role hierarchy are granted Full Access to the record. It is not possible to grant other users Full Access. Users with the “Modify All” object-level permission for the given object or the “Modify All Data” permission can also manually share a record. User managed sharing is removed when the record owner changes or when the access granted in the sharing does not grant additional access beyond the object's organization-wide sharing default access level.

Apex Managed Sharing:-
Apex managed sharing provides developers with the ability to support an application’s particular sharing requirements programmatically through Apex or the SOAP API. This type of sharing is similar to Force.com managed sharing. Only users with “Modify All Data” permission can add or change Apex managed sharing on a record. Apex managed sharing is maintained across record owner changes.

48. What are the Mandatory points that you think while creating User, Role or Profile?
Profile is mandatory and role is optional.

49. How can i provide record level access to user’s in an organisation?

You control record-level access in four ways. They’re listed in order of increasing access. You use org-wide defaults to lock down your data to the most restrictive level, and then use the other record-level security tools to grant access to selected users, as required.

Org-wide defaults specify the default level of access users have to each other’s records.

Role hierarchies ensure managers have access to the same records as their subordinates. Each role in the hierarchy represents a level of data access that a user or group of users needs.
Sharing rules are automatic exceptions to org-wide defaults for particular groups of users, to give them access to records they don’t own or can’t normally see.
Manual sharing lets record owners give read and edit permissions to users who might not have access to the record any other way.

50. If i want Object level accesses then what should i use from Salesforce security model?
For Object-Level Security you can use Permission Sets or Profiles.

51. What is grant access using hierarchies in OWD?
When Grant Access using Hierarchy is checked for a custom object(For standard objects this is always checked) even if the record is private, users higher in the role than the owner of the record still gets access to the records.

A simple example can be assumed opportunity is private OWD and you are Sales Rep owning an opportunity record, you have your manager who is higher in the role hierarchy than you, even though the opportunity is private he will still get access to your records.

52. Is it possible to changed Grant Login access using Hierarchies in case of standard objects?
By default, the Grant Access Using Hierarchies option is enabled for all objects, and it can only be changed for custom objects.

53. While setting OWD (Organization wide sharing), can we change/modify the setting of child record in case of Master-Detail relationship?
No, Child record is controlled by the Parents setting.

54. What is Workflow rule? How many types of workflow action salesforce has?
Workflow rules can help automate the following types of actions based on your organization's processes:

Tasks: Assign a new task to a user, role, or record owner.
Email Alerts: Send an email to one or more recipients you specify.
Field Updates: Update the value of a field on a record.
Outbound Messages: Send a secure, configurable API message (in XML format) to a designated listener.

55. what is the different type of evaluation criteria workflow has?
Workflow has three types of evaluation criteria-
1. Created
2. Created, and every time it’s edited.
3. Created, and any time it’s edited to subsequently meet criteria.

56. How many types of workflow rule in salesforce?
Salesforce.com has a two types of workflow rules-

1. Immediate Workflow rule:-
Workflow rule fires immediately when the workflow criteria is met, and the associated actions (email alert/field update etc.,) will take place immediatlely.

2. Time Dependent Workflow rule:-
When the workflow entry criteria is met, associated actions (email alert/field update etc.,) will take place after a certain period of time. This time is based on the value that you set.

57. What are the limitations of Time-dependent workflow?
Time triggers don’t support minutes or seconds.
Time triggers can’t reference the following:
DATE or DATETIME fields containing automatically derived functions, such as TODAY or NOW.
Formula fields that include related-object merge fields.
You can’t add or remove time triggers if:
The workflow rule is active.
The workflow rule is deactivated but has pending actions in the queue.
The workflow rule evaluation criteria are set to Evaluate the rule when a record is: created, and every time it’s edited.
The workflow rule is included in a package.

58. In case of Master-Detail relationship, on Update of master record can we update the field of child record using workflow rule?
No,You need trigger or process builder to update child object from master.

59. In which criteria of a workflow – “time dependent workflow action” cannot be created ?
Created, and every time it's edited.

60. We have a “Time Based Workflow” and there is Action scheduled to be executed. If we Deactivate the workflow, Scheduled actions will be removed from queue or not?
Yes, Scheduled actions will be removed from queue.

61. What is approval process?
An approval process is an automated process your organization can use to approve records in Salesforce. An approval process specifies the steps necessary for a record to be approved and who must approve it at each step. A step can apply to all records included in the process, or just records that have certain attributes. An approval process also specifies the actions to take when a record is approved, rejected, recalled, or first submitted for approval.

62. What is the difference between workflow rule and process builder?
You can use the Process Builder to perform more actions as comparision to workflow rule:-
Create a record
Update any related record
Use a quick action to create a record, update a record, or log a call
Launch a flow
Send an email
Post to Chatter
Submit for approval
Call apex methods
But the process builder doesn’t support outbound messages.

Workflow rule has only 4 actions:-
Create Task
Update Field
Email Alert
Outbound Message

63. Mention changing what may cause data loss?
Only convert custom fields for which no data exists or you risk losing your data. Changing the data type of an existing custom field can cause data loss in the following situations:
Changing to or from type Date or Date/Time
Changing to Number from any other type
Changing to Percent from any other type
Changing to Currency from any other type
Changing from Checkbox to any other type
Changing from Picklist (Multi-Select) to any other type
Changing to Picklist (Multi-Select) from any other type

Currently defined picklist values are retained when you change a picklist to a multi-select picklist. If records contain values that are not in the picklist definition, those values will be deleted from those records when the data type changes.
Changing from Auto Number to any other type
Changing to Auto Number from any type except Text
Changing from Text Area (Long) to any type except Email, Phone, Text, Text Area, or URL

64. How many ways we can perform data migration into the salesforce?
1) Salesforce Import Wizards
2) Dataloader
3) Workbench
4) Apex CLI
5) Apex Data Loader
6) Force.com Excel Connector
7) DemandTools
8) Jitterbit Data Loader for Salesforce
9) Informatica Cloud Data Loader for Salesforce

65. How to insert null values into data loader?
To check Insert null values checkbox in dataloader.

66. What is the minimum and maximum batch size of data loader?
The max batch size of dataloader is 10K when using Bulk and minimum 1, otherwise it's bydefault 200.

67. Difference between Import Wizard and Dataloader?
Import Wizard :
Is designed for less-technical users and smaller, simple imports of up to 50,000 records.
Can only import data from Account, Contact, Leads, Solution, and Custom Object.
For more information, go to Help & Training | Importing Data | Using the Import Wizards.

Data Loader :
For complex imports of any size.
Can upload more than 50000 records.
Can import and export data.
Can import data of any object except User.

68. How many types of reports in Salesforce?
There are four type of reports

1. Tabular report: This is the most basic report. It displays just the row of records in a table like a format with the grand total. Tabular reports cannot be used for generating dashboards.

2. Summary report: This is the most common type of report. It allows grouping of rows of data. It supports sorting and displaying subtotals. For example in a recruiting app, a summary report could be used to display open positions classified by department name.

3. Matrix report: This is the most complex report format. Matrix report summarizes information in a grid format. Matrix reports allow records to be grouped by both columns and rows.

4. Joined reports: A joined report can contain data from multiple standard or custom report types. You can add report types to a joined report if they have relationships with the same object or objects. For example, if you have a joined report that contains the Opportunities report type, you can add the Cases report type as well because both have a relationship with the Accounts object.

69. What is bucketing in reports?
Bucketing lets you quickly categorize report records without creating a formula or a custom field within Salesforce.When you create a bucket field, you define multiple categories (buckets) that are used to group report values.

70. How many records we can display on the page for a report?
Rows displayed in a report Up to 2,000. To view all the rows, export the report to Excel or use the printable view for tabular and summary reports. For joined reports, export is not available, and the printable view displays a maximum of 20,000 rows.

71. Is it possible to schedule a dynamic dashboard in Salesforce?
No

72. Mention what is the use of static resource in Salesforce?
Static resources allow you to upload content that you can reference in a Visualforce page, including archives (such as .zip and .jar files), images, style sheets, JavaScript, and other files.

73. What is custom label?
Custom labels are custom text values that can be accessed from Apex classes or Visualforce pages. The values can be translated into any language Salesforce supports.
You can create up to 5,000 custom labels for your organization, and they can be up to 1,000 characters in length.

74. What is custom setting?
Custom settings are similar to custom objects and enable application developers to create custom sets of data, as well as create and associate custom data for an organization, profile, or specific user. All custom settings data is exposed in the application cache, which enables efficient access without the cost of repeated queries to the database. This data can then be used by formula fields, validation rules, flows, Apex, and the SOAP API.

There are two types of custom setting:
List Custom Settings
Hieriarchal Custom Settings.

75. Why we used the Tab in Salesforce and mention the types of Tab?
Custom tabs display custom object data or other web content embedded in the application.

Custom Object Tabs: For your custom object data. Custom Object Tabs display the data of your custom object in a user interface tab. Custom object tabs look and function just like standard tabs.

Web Tabs: For other web content Custom Web Tabs display any external Web-based application or Web page in a Salesforce tab. You can design Web tabs to include the sidebar or span across the entire page without the sidebar.

Visualforce Tabs: For Visualforce pages Visualforce Tabs display data from a Visualforce page. Visualforce tabs look and function just like standard tabs.

Flexible Page Tabs: For Flexible Pages, to include them in the Salesforce1 navigation menu. Flexible Page Tabs let you add Flexible Pages to the Salesforce1 navigation menu.

76. Available portals in Salesforce?
Three types of portals are available in salesforce.com
1. Customer Portal: This gives us to utilize the capabilities of the Web as the ideal channel to deliver superior self-service.
2. Partner Portal: This allows partner users to login to Salesforce via a separate website than our non-partner users.
3. Self Service Portal: Customers will able to search organization knowledge using this portal.

77. How many ways we can deploy our work one org to another org in Salesforce?
Different Deployment Methods

1. Change Sets
2. Eclipse with Force.com IDE
3. Force.com Migration Tool – ANT/Java based
4. Salesforce Package

78. What are the differences between 15 and 18 digit record IDs?
A 15 digit Salesforce ID is case sensitive. Ex: 00570000001ZwTi and 00570000001ZWTI are different.
A 18 digit Salesforce ID is case in-sensitive. Ex: 00570000001ZwTiXYZ and 00570000001ZWTIXYZ are same.

79. Why is it necessary for most sales teams to use both Leads and Contacts?
Once you convert the lead, the lead record is no longer accessible via the UI. So to access any of the personal contact information that was captured on lead records, sales team use the contact record.

80. What is the difference between Task and Event?
An event is a calendar event scheduled for a specific day and time.
Examples of events are:
- Meetings
- Scheduled Conference Calls

A task is an activity not scheduled for an exact day and time. You can specify a due date for a task or there may not be a particular time or date that the tasks or activities need to be completed by.
Examples of tasks are:
- A list of phone calls you need to make.
- An email that needs to be sent.

81. What is WhoId and WhatId in activities?
WhoID refers to people. Typically: contacts or leads. Example: LeadID, ContactID

WhatID refers to objects. Example: AccountID, OpportunityID, CustomObjectID

82. What is an external ID in Salesforce? Which all field data types can be used as external IDs?
An external ID is a custom field which can be used as a unique identifier in a record. External IDs are mainly used while importing records/ data. When importing records, one among the many fields in those records needs to be marked as an external ID (unique identifier).

An important point to note is that only custom fields can be used as External IDs. The fields that can be marked as external IDs are Text, Number, E-Mail, and Auto-Number.

83. What is Audit Trail?
Audit Trail is a function that helps track all the changes performed by different administrators to the Organization in the past 6 months. It covers details such as

Date of changes made
Username that made the changes
Details of the changes made

84. Is it possible to edit formula field values in a record?
No you can't edit formula field on a record. Formula fields are read only fields in Salesforce.

85. How many ways we can made field is required?
While creation of field
Validation rules
Page Layout level

86. What are outbound messages?what it will contain?
Outbound messaging allows you to specify that changes to fields within Salesforce can cause messages with field values to be sent to designated external servers. Outbound messaging is part of the workflow rule functionality in Salesforce. Workflow rules watch for specific kinds of field changes and trigger automatic Salesforce actions, such as sending email alerts, creating task records, or sending an outbound message.
outbound message contains end point URL.

For more information

87. Salesforce sites?
Used to show data from our organization for public view.

88. Auto-response rules and Escalation rules(for which objects are mandatory)?
Case and Lead.

89. Why we create debug log for users?
For tracking code.

90. When a case is generated by an user through web to case,how or where a developer will provide solution case arised?
Email notification through trigger or through email alert Workflow rule.