Salesforce Interview Question and answers for Developers Part 9

49. What is the significance of master detail relationship?
Ans - Master detail relationship can be set by creating master detail field on the detail object. In master detail relationship whenever a master detail record is deleted the detail records are also deleted. When creating a detail record it is mandatory that the master field is populated with a value(i.e master field is mandatory) It is also mandatory that this field is kept on pagelayout. A standard object can never be set as detail object. With master detail relationship roll up summary fields can be created on master object.

50. What is trigger recurssion and how can you you avoid it?
Ans - If an exceting trigger calls itself then it goes to into infinite loop and is called recursion. If a trigger on a particular object executing on a particular dml does the same dml on that object then the same trigger would be called and it will go into recursion. A static variable can be set in a class before executing the trigger to avoid the recursion.

51. What is an external id?
A external id is field that can be used as a reference while updating records. If the data is coming from an external system then the unique field that the external system has could be used as an external id within salesforce. External id can be used while upserting records within salesforce using data loader. There is a limit on the number external ids you can have in an object.

52. What are governers limit and what is its significance?
Ans - Governers limit is a limit that salesforce enforces on every code execution so as to avoid monopoly by any single org. Since the resources are shared across organisation governer limit checks on the resource utilisation. Number of limits are imposed limit 100 soql query exception, 50000 rows can be fetched using soql etc

53. Why one should not put a soql or a dml within for loop?
Ans - Putting soql or dml in for loop can easily hit the governer limit hence we should not put them in for loop. Only 100 soql are allowed in one transaction and only 150 dmls are allowed.

54. What are the various collections available in salesforce?
Ans - In salesforce along with primitive data types and sObjects there are collections. Apex uses following collections as below
    List - stores duplicate values which are ordered.
    Set - stores unique values which are unordered
   Map - consists of keys and values

Salesforce Developer Interview Question and answers part 8

 Next>>> Part 9[Questions 49-54]

43. What is the significance of ID data type in salesforce?
Ans - Every record in salesforce is represented using a parameter called as id. Salesforce uses Data type ID for storing such record id's. An ID is represented in terms of 15 digit or 18 digit. 15 digit id is case sensitive where as 18 digit id is case insensitive. First 3 characters of ID indiacte the object for example 001 means its an account record or 006 means its an opportunity record.

44. What is the difference between a List and Set?
Ans - A List and Set are both collections similar to array with following differences
 List can store duplicate values in it, set can store only unique values
List can store primitive types,sObject as well as collections in it,Set can store primitive and sObjects but not collection
List is Ordered where as set is unordered.

45. What are the various primitive data types available in salesforce?
Ans - Various primitive data types in apex include following
  Decimal, double, integer, Long, String, Id, date. datetime, time, currency, boolean

46. What is a map collection? and how is it different from list and set?
Ans - A map consists of key and values. Keys are unique while values can be duplicated. Every key points to a value. Using methods we can retrieve the values using the keys or store key-values mappings. map is useful in storing relationships between to parameters. Key is similar to set which can only store primitive types where as values are like set that can also store collections in it. There are number of methods that can be used to manipulate data in map.

47. What is an sObject data type?
Ans - sObject is a data type that can store standard or custom object in it. Account for example is a sObject type of data.
ex-   sObject sO = new account()

48. What is a sandbox.? what are the different types available?
Ans - sandbox is a test environment used for developing or testing the functionality. It is an exact copy of your production org. Sandbox can be full sandbox, Developer sandbox, Developer Pro, Partial Data sandbox

 Next>>> Part 9[Questions 49-54]

Salesforce Developer Interview Question and Answers For Developers Part 7

37. What are the various ways of deployment in salesforce?
Ans - Metadata components in salesforce can be deployed using various ways as below
         Change set, Eclipse IDE, ANT, Workbench
38. What is an account team?
Ans - Account team is group of users that work on a articular account. The users in a account team can be given access depending on the need. A account team appears as related list on account.
39. How to override a custom button on object with a visualforce page?
Ans - Inorder to override a button with a visualforce page the page needs to use standard controller of that obejct. For example a account button can be overriden with visualforce page provided the page uses account standard controller.
Ex   <apex page standardcontroller ="Account">
40. What are various email templates types available in salesforce?
Ans - Email templates used in salesforce could be text, html, custom html or visualforce type

41. What is the difference between rendered and rerender in visualforce page?
Ans - rendered can be used to hide or show a particular section of the page. It is mapped to a boolean variable that can set which shows or hides or executes that section or component. Rerender is used to refresh a section or component of the page. In Rerender the ids of the section need to be specified comma separated.
42. How can you expose a apex class as web service? and how to obtain a wsdl file for exposed class?
Ans - In order to expose a class as a webservice we have to use keyword 'webservice' with the method also the method should be global and also the class should be defined global. ex-
Global class webClass{
 global webservices void mymethod(){
A wsdl file for a apex class can be obtained by using the button generate wsdl on class.

Next>>>Part 8 [Questions 43-48]

Salesforce Interview Question and Answers For Developers Part 6

Next>>> Part 7 [Questions 37-42] 

31. What are custom controllers?
Ans - Custom controller is nothing but a apex class that associates itself with a visualforce page that does not use any standard controller. All of the visualforce functionality is custom defined and no standard page functionality is directly available. In a visualforce page the custom controller is defined by keyword controller. ex <apex page controller ="mycustController" >

32. How can standardcontroller functionality be extended?
Ans - This can be done using associating a class using extensions.

 33. Can a visualforce have more than one extenssions?
Ans - Yes, a standard controller can have more than one extension.
34. How can you place an entire visualforce page in another visualforce page?
Ans - This can be done using attribute include. We have to just specify the name of the visualforce page and include this attribute in our visualforce page.

35. What are various standard exceptions that salesforce throws?
Ans - salesforce throws number of standard exception . Some of the important ones are as below-
 dmlexception, listexception, email exception, calloutexception, JSONexception, mathexception, Queryexception, sObjectexception, xmlexception, typeexception, visualforceexception, stringexception, searchexception, nullpointerexception, noaccessexception,

36. What is the significance of profile?
Ans - A profile is associated with a user. Every user will have a profile. A profile is used to define a user's permission to do various functions within Salesforce. A profile controls various permission as below, (Object permissions, tab,record type, report type, application permission, visualforce pages, classes, login hours, ip ranges from where user can log in, field permission, pagelayouts

Next>>> Part 7 [Questions 37-42] 

Salesforce Interview Question and Answers Part 5

Next>>> Part 6 [Questions 31-36]

25. What is a workflow rule?
Ans - A workflow rule is a set of actions that can be executed when a record is created or edited. A workflow rule consists of criteria when a workflow rule is executed and actions. Criteria when a workflow rule gets executed could be either of the following,
  • Created
  • Created and every time it’s edited
  • Created, and every time it’s edited.
Actions could be field update, task assignment, email alert or outbound messages. These Actions could be immediate or time dependent. 

26.  What is an approval process?
Ans - An approval process is a process which can be used to approve records . An approval process consists of steps necessary for a record to get approved/rejected, user who must approve it or reject it. Approval process also specifies what actions to be taken when a record is approved, rejected or rejected.

27. What is the difference between Role and profile
Ans - Role determines what record is visible to a user while a profile determines what actions they are allowed to perform on that object. That is, we can say that profile defines Object level access, field level access while Role defines Record level access. Profile is used give access to Tabs, fields via FLS, General and Administrator settings. Role hierarchy can be maintained, this gives access to records in hierarchy manner.

28. What is data loader and what can be done using data loader?
Ans - Data loader is tool that can be used to extract salesforce data and also insert/update salesforce data. Data loader can also be used for bulk data delete,insert or update. It uses api for operation. Some of the features of data loader are as below
  • Drag-drop field mapping
  • Standard as well as custom objects are supported
  • Provides success and error log files in CSV format
  • Supports insert, update, delete, extract data operations
29. What is lead conversion?
Ans - A lead conversion means transition of a prospect into an account, contact and a possible opportunity. Technically a lead record when converted creates an account record, a contact record and optionally an opportunity record. There is also a provision to create task. A converted lead cannot be accessed from salesforce UI. 

30 . What are analytical snapshot?
Ans - Analytical snapshots can be used to schedule a report run and then save the report result as records in custom object. While building a analytical snapshot we have to select a source report and destination object. Then map the fields from report and object. The report runs at specified time and then inserts the report result as records in that object. Advantages that we get through analytical snapshot are as below, Runs reports faster, Sot and filter data using list views, can view trend in data via object records. The object selected for record insertion should not have any insert trigger on it.

Next>>> Part 6 [Questions 31-36]

Salesforce Interview Question and Answers For Developers Part 4

Next>>> Part 5 [Questions 25-30]

19. What is territory management
Ans - A territory is a collection of accounts and user where in minimum read access can be given to the account. Territory management is nothing but account sharing mechanism based on account data. Territory management affects account and objects that have master detail relationship with account.
Territory management gives and ability to expand sharing model based on account data. A territory can have multiple users, also a user can present in multiple territories. Criteria based on account data can be set, and based on that criteria access level can be set for the users under that territory.

20. What is apex sharing?
Ans - Like manual sharing using configuration, records can also be shared using apex. Every object has associated share object where records can be inserted to share records with group or a user. For example account has accountshare, case has caseshare etc. Record access level, row cause, user/group can e specified while inserting the share records.

21. What is manual sharing in salesforce?
Ans- Using manual sharing rules we can grant wider access to data to a set user. This can only used to give more access and not to restrict access to data. While writing a sharing rule we have to give criteria on which record should be shared(Based on record owner or defined criteria), To whom the record should be shared(Group,role or role and sub ordinate) and the access level(Read only, read/write). Manual sharing is available for some standard objects and all the custom objects. 

22. What is OWD and its significance?
Ans - Organization wide default is used to set default access level for various standard objects and all custom objects. Default access can be set as Public read only, Public read write, Public read write and transfer for different objects. For example if the record access level is set to private then the records will be accessible only to owners, users above in role hierarchy and if it shared using manual sharing. Using OWD we can also set if the records can be set using role hierarchy for custom objects (For standard objects records are always shared using role hierarchy).

23. What is test coverage and what is its significance?
Ans - Apex code written in salesforce needs to tested using test classes. Apex code gets test coverage depending on the logic written in test class. The functionality implemented in an apex class has to be tested using test class. Salesforce does not allow deployment if the entire org has coverage less than 75%.

24. What are standard controllers in visualforce?
Ans - Standard controller when used in a visualforce page gives the same functionality and logic as used for standard pages. For example standard button save functionality will be avaibale as it is and we need not write any method to execute it. Similarly it also gives all the action behaviour and look and feel of the standard object. To specify a visualforce page as standard controller we have to specify standardcontroller="objectname"
 ex- <apex:page standardController="Account"> 

Next>>> Part 5 [Questions 25-30]

Salesforce Interview Question and Answers For Developers Part 3

Next>>> Part 4 [Questions 19 -24] 

13. What is a wrapper class in apex?
Ans- A wrapper class is user defined type. We can set the properties of this type as per our requirement. similar to standard data types we can create collections of the wrapper class too. Wrapper class will be a inner class with a constructor in which the parameters are set. For example a wrapper could be combination of data contained in two different objects. A standard data type always allows to store data which of a single type, so we can say that whenever we have to collect data of different types we have to use wrapper class.

14. Reports in salesforce, what are the different types?
Ans - Reports gives access to the data that organisation has collected over a period of time. Reports return set of records depending on criteria used. Data is displayed as columns and rows. A report can be configured with filter criteria and also grouped and displayed as chart. Reports are stored in folders. Following are the different types of reports available in salesforce
  • Tabular
  • Joined
  • Summary 
  • Matrix
The report can also be extracted as an excel sheet.

15. Dashboards in salesforce, what are the different types?
 Ans - A dashboard displays data in a graphical way using data contained in a report. That is data source is one of the report(summary or matrix), this data can be displayed in a component. Following are the different types of dashboards components available in salesforce
  • Chart(Bar, Line,Pie,Donut, Funnel)
  • Guage
  • Metric
  • Table
  • Visualforce
A dashboard can be viewed as either logged in user(dynamic dashboard) or as a specified user(static)

16. What is a report type?
Ans - A report type is a skeleton over which you can build the report. It specify the structure of your report(Object relationship). Salesforce provides standard report types using which reports can be build. If the standard type does not suffice your requirement then we have to go for custom report type. It allows to build framework from which reports can be created. While building report type we need to select object and the relationship between objects to display in report. Which fields will be available for display can also be set.

17. What is a record type?
Ans - Using record type we can set different page layouts, picklist values and business processes to different users.
A profile can be set with a default record type or the user can be given option to select the record type before creating the record. Record type is can be created for both standard as well as custom objects.

18. What is trigger code?
Ans - A trigger is a piece of code that executes on dml on a particular object. The code can be made to run on multiple events like update, insert, delete, upsert etc but  a particular trigger code will only on single object. If multiple records initiate a trigger code then all of those records are available in list. A trigger code should always be bulkified , that is it should be able to handle all the records.

Next>>> Part 4 [Questions 19 -24] 

Salesforce Interview Question and Answers for Developers Part 2

Next>>> Part 3[Questions 13-18]

7. What are different trigger context variables and what is their significance? 
Ans - Trigger context variable are the various parameters that have information about records that initiated the trigger. They are also the variables that store information about currently executed trigger. Various important context variable are as below
  • - holds list of records that initiated the trigger code
  • trigger.old- older version of the records that initiated the code
  • trigger.isinsert - boolean variable that states whether the trigger is initiated because of insert operation(similarly there are update,delete etc of this type)
  • trigger.oldmap,trigger.newmap,trigger.isupdate, trigger.isafter,trigger.isbefore are some of the other context variables.
8. What are trigger.old and variables?
Ans - These are lists that store all the records which have called the trigger code. holds the newer version of the records while trigger.old is the original version of the records. For example if the trigger is called on update then the will have newer values to be updated while trigger.old will have values that were already existing in the data base. Both of these together can be used for comparing fields values if they are changed.

9. How to catch exceptions in apex?
Ans - Exceptions in apex can be catched using try catch blocks. The code that is susceptible to exception should be put in try block, the thrown exception can be handled in catch block, optionally a final block can also be used(final block is always executed at the end). The catch block takes in parameter which could be generic exception or standard thrown exception(listexception, dmlexception etc) or could also be custom defined exception.

10. What is a developer console?
As - Developer console is framework which can be used to run a anonymous piece of code, it can be used to execute test classes, monitor test coverage and for debugging purpose. It is very helpful in testing, validating the performance , debugging troubleshooting,and executing soql, sosl or any short short apex code on the fly.

11. What is the difference between action function and action support?
Ans - Both action support and function can be used to call a controller method using an AJAX request.
Action function can call the controller method from java script.
Action support adds AJAX support to another visualforce component and then call the controller method.
Action function cannot add AJAX support to another component. But from a particular component which has AJAX support(onclick, onblur etc) action function can be called to call the controller method.

12. What are custom settings?
Ans - Custom settings are similar to custom objects. Custom sets of data can be created using custom settings which can then be referred in apex code, salesforce api, formula fields or validation rules. The advantage of using custom setting is that there is no need to fire query. There number of methods that can be used to extract and manipulate data in custom settings. Types of custom settings include List and Hierarchical custom settings.

Next>>> Part 3[Questions 13-18]

Salesforce Interview Question Answers for Developers Part 1

Next>> [Part 2 Questions 7-12]

1. What is a custom label?
Ans - Custom labels are used to store static string values which can be used coding i.e in apex or visualforce pages. They can also be used for language translation, i.e we can define values in different languages and use them in apex/visualforce pages. There is a limit on the length of the string that can be stored in label.

2. What are the different actions available in workflow?
Ans - A workflow has following actions
Field update - either of the same object or cross object field update(In case of some objects only)
task create - create and assign the task to a user
email alert -  send a email to user or group of user with a selected email template Outboud messages - send field values as outboud message to desired url link

3. What are the different api's available in salesforce?
Ans - The API's provided by salesforce include - SOAP API, REST API, METADATA API, BULK API
SOAP - SOAP API can be used to create, retrieve, update or delete records, can be used with any language that supports web services
REST - Its a REST-based Web services interface for interacting with Salesforce application
METADATA - cab be used retrieve, deploy, create, update, or delete customisations in the salesforce organisation. This can be used in making tools that can manage metadata within the org
BULK - It is based on rest api principle and can be used for loading or deleting large set of data

4. What is a role hierarchy?
Ans -Role hierarchy is a tree that places one role below the other. A role can have many child's but a role can have only one immediate parent. Roles are basically used for setting record level access using OWD. When an object has share records using role hierarchy it means the the user placed higher in role hierarchy will get access to the records owned by the users placed lower in the role hierarchy. Standard objects records are always shared using role hierarchy. It can be disabled only for custom objects.

5. What are different object relationships in salesforce?
Ans -Salesforce objects can be related to each other using following relationships
Look up relationship, Master detail relationship, many to many relationship,self relationship(hierarchical relationship)
Lookup Relationship - This can be created using a simple lookup field on the child. Default settings does not make the field mandatory however it can be made mandatory by setting so.
Master Detail Relationship - This can be set up using master detail relationship field. A master record when deleted deletes the detail records. With this kind of relationship we can create roll up summary fields on master object. Note that a master object can never be a detail object.
Many to many Relationship - this can be developed with a junction object which has two master detail fields to the two objects.

6. What is a formula field?
Ans -A formula field is a read only field that calculates at run time and returns output depending on the expression used in its definition. It is updated every time the source field values are changed. It can have return type as any of the below,
  • checkbox 
  • currency 
  • date 
  • datetime 
  • number 
  • percent 
  • text