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]

No comments:

Post a Comment