Salesforce Interview Questions – Part 11

101. How to force lead assignment rule via Apex while updating or adding the Lead?
Ans : To enforce Assignment Rules in Apex you will need to perform following steps:

  1. Instantiate the “Database.DMLOptions” class.
  2. Set the “useDefaultRule” property of “assignmentRuleHeader” to True.
  3. Finally call a native method on your Lead called “setOptions”, with the Database.DMLOptions instance as the argument.


// to turn ON the Assignment Rules in Apex
Database.DMLOptions dmlOptn = new Database.DMLOptions();
dmlOptn.assignmentRuleHeader.useDefaultRule = true;

102. How to implement the pagination in SOQL ?

In spring 12, Salesforce has come up with ability of SOQL to get records from position “X” instead of position “1” every time to help creating pagination feature.

Pagination in SOQL using keyword Offset
Pagination in SOQL using keyword Offset


Select Id, Name from Lead LIMIT 5 OFFSET 2

Above query will return 5 Lead records starting from record number 10 (5×2).

Read more here about SOQL pagination Continue reading “Salesforce Interview Questions – Part 11”