Deepanshu Singh
IndividualForum Replies Created
-
Deepanshu Singh
MemberApril 17, 2020 at 1:03 pm in reply to: How we can add wrapper class instances in list in Salesforce?I don't know what exactly you are trying to do. Please be more brief, Anyways, wrapper class instance can be added easily in list by these few statements. List<wrapperClass> wrapClassList = new List<wrapperClass>();
wrapClassList.add(new wrapperClass(arg1, arg2)()); -
Deepanshu Singh
MemberApril 15, 2020 at 1:02 pm in reply to: How to add Lighting page in an lighting app in Salesforce?Goto App Manager > select lightning app > add your lightning page > finish
-
Deepanshu Singh
MemberMarch 31, 2020 at 1:28 pm in reply to: Why apex trigger is written in handler class?It is done to improve the readability and cleanliness of the code
-
Deepanshu Singh
MemberJanuary 18, 2020 at 5:40 pm in reply to: How can we avoid recursive trigger execution in Salesforce?Recursive Trigger problem occurs usually on update Trigger, you have solve the problem by adding this code :
public class CheckRecursive { private static boolean run = true; public static boolean runOnce() { if(run) { run = false; return true; } else { return run; } } }
if((Trigger.isBefore || Trigger.isAfter) && Trigger.isUpdate ))
{
if(CheckRecursive.runOnce()) {
// your further code here
}
}
-
Deepanshu Singh
MemberJanuary 18, 2020 at 5:27 pm in reply to: how can you optimize SOQL query to fetch data from Salesforce Database?Avoid the inner Queries, follow the best practices
-
Deepanshu Singh
MemberJanuary 18, 2020 at 5:24 pm in reply to: How can write the Aggregate query and display the result of Aggregate query in Salesforce ?For the Aggregate Query you have AggregateResult class in apex
Example
for(AggregateResult ar : [select count(Id), AccountId from Contact where AccountId in :accset group by AccountId having count(Id)>2 ]) { contList.add(new Contact(Id = (ID)ar.get('AccountId'))); } try{ update contList; }catch(DMLException exc){ system.debug("Exception => " + exc.getMessage()); }
-
Deepanshu Singh
MemberJanuary 18, 2020 at 5:14 pm in reply to: How to prevent duplicate record without using Apex Trigger in Salesforce?Go to Quick Find, type duplicate Rules , untick the old rules or create a new Rule which defines duplicate not allowed
-
Deepanshu Singh
MemberJanuary 18, 2020 at 5:09 pm in reply to: How can we fetch/retrieve only one contact from account in SOQL Query in Salesforce?set<id> accountids = new set<id>(); for(Contact con : Trigger.New) { accountids.add(con.AccountId); } List<account> accList = [ select Name, (select AccountId, firstName, lastName from Contacts where AccountId =: accountids limit 1) from Account ];