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:
- Instantiate the “Database.DMLOptions” class.
- Set the “useDefaultRule” property of “assignmentRuleHeader” to True.
- 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; leadObj.setOptions(dmlOptn);
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.
Select Id, Name from Lead LIMIT 5 OFFSET 2
Above query will return 5 Lead records starting from record number 10 (5×2).