Salesforce Interview Questions – Part 3

Author posted by Jitendra on Posted on under category Categories Salesforce and tagged as Tags , , with 29 Comments on Salesforce Interview Questions – Part 3

Most Frequently Asked interview questions of Apex, Visual force, SOQL in Salesforce.com SFDC

20. In Which sequence Trigger and automation rules run in Salesforce.com

Ans : 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
  5. Custom Validation Rules
  6. Record saved to database (but not committed)
  7. Record reloaded from database
  8. All Apex “after” triggers
  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.


21. 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?

Ans : 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. By having all logic in one trigger you may also be able to optimize on your SOQL queries.


22. How to delete the User from Salesforce?

Ans : As per now, salesforce does not allow to delete any user, however you can deactivate the user.

Read further…


23. How to delete the users data from Salesforce?

Ans : To delete the Users Data go to Setup | Administration Setup | Data Management |  Mass Delete Record, from there select the objects like Account, Lead etc and in criteria select the users name and delete all records of that user related to particular object.


24. How to restrict the user to see any record, lets say opportunity?

Ans : set up opportunity sharing to be private.  If both users are admins or have view all records on opportunity, then that overrides private sharing.


25. What is the difference between trigger.new and trigger.old in Apex – SFDC?

Ans :

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, and 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.


26. How to restrict any Trigger to fire only once OR how we can avoid repeated or multiple execution of Trigger?

Ans:

Triggers can fire twice, once before workflows and once after workflows, this is documented at

http://www.salesforce.com/us/developer/docs/apexcode/ Content/ apex_triggers_order_of_execution.htm:

“The before and after triggers fire one more time only if something needs to be updated. If the fields have already been set to a value, the triggers are not fired again.”

Workaround:

Add a static boolean variable to a class, and check its value within the affected triggers.

public class HelperClass {
   public static boolean firstRun = true;
}
trigger affectedTrigger on Account (before delete, after delete, after undelete) {
    if(Trigger.isBefore){
        if(Trigger.isDelete){
            if(HelperClass.firstRun){
                Trigger.old[0].addError('Before Account Delete Error');
                HelperClass.firstRun=false;
            }
        }
    }
}

27.  What is difference between WhoId and WhatId in the Data Model of Task ?

Ans :

WhoID refers to people things. So that would be typically a Lead ID or a Contact ID
WhatID refers to object type things. That would typically be an Account ID or an Opportunity ID

Check Data Model of task here


28. Where is the option of the report for the “Custom Object with related object” and what are the condition to generate related reports?
Ans :

If the parent object is the standard object provided by the salesforce like “Account”, “Contact” then the report will be in there section with related custom object.
If both objects are the custom then the report will be in “Other Reports” Sections.

Following are the conditions to get the report of related objects:

  • On both the objects, Reports option must be enable.
  • Both object must be related either using Lookup or Master Detail type of field.

Read this article, to get detailed idea on this topic.


29. How you can provide the User Login (Authentication) in Public sites created by Salesforce.

Answer : We can provide the authentication on public sites using “Customer Portal”.


Related posts

29 thoughts on “Salesforce Interview Questions – Part 3”

  1. Hello Jitendra,
    i learning salesforce aiming for a developer position, can you please send me any links to learn apex, will be looking forward to hear from you.

  2. Great interview questions.

    I was self-studying how to develop on Force.com platform. My intention is to work on Force.com platform as a cloud developer. I had 3 years of experience in developing web apps in Java. Do you think there will positions available in the market for the guys like who has no professional experience in developing Salesforce.com’s appliation?

    Thank you and I appreciate your help.

  3. hi iam tiresh reddy working on salesforce..i was please with your blog which was posted by u..thanks for that..plz accept my add request n plz do send any updates on salesforce along with some interview questions..

    1. Hi Towfeeq,
      In most of the cases logged in user will be same as running user.
      However, there are scenario like logged in user does not have permission to see some dashboard or report in that case we can set the running user so that logged in user can have access to those data.
      I hope it clears your doubt.

    1. Thanks Abhi,

      URL provided by you says – If the request came from a standard UI edit page, Salesforce runs system validation to check the record for :

      So, above sequence is still there.

  4. Nice job Jitendra. Thank you so much for sharing your knowledge. Hope this is not late to appreciate your good work.
    Reg, Q.No 28: You mentioned that, Condition to create reports between two objects is, should be master detail relations ship. But I have created look up relation. Still I am able to see reports for both objects (in Other Reports ). But I have observed a difference. i.e.

    Ex: Obj names: Master and Child

    Master-Details relation ship: Master with Child

    Look up relation: Child with Master.

    My question is. is this new feature given by Salesforce or was already there.

  5. Hi Jitendra..
    In OOE for point no: 4 & 8, you mentioned like EE & UE only, Does this mean the Apex triggers executes only in the EE & UE ??

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.