You need to sign in to do that
Don't have an account?
BigP
Can somebody explain the meaning of each line of this code?
Trigger SalespartnerUpdate on Job__c(after insert, After Update){
Map<id, id> accwithspmap = new map<id,id>();
for(job__c j:trigger.New){
if(j.Account__c!=Null && j.SalesPartner__c!=Null){
accwithspmap.put(j.Account__c,j.SalesPartner__c);
}
}
List<Account> acclistupdate = new List<Account>();
for(Account acclist: [Select id,SalesPartner__c from account where id=:accwithspmap.keyset()]){
If(accwithspmap.containskey(acclist.id)){
acclist.SalesPartner__c = accwithspmap.get(acclist.id);
acclistupdate.add(acclist);
}
}
Update acclistupdate;
}
}
Map<id, id> accwithspmap = new map<id,id>();
for(job__c j:trigger.New){
if(j.Account__c!=Null && j.SalesPartner__c!=Null){
accwithspmap.put(j.Account__c,j.SalesPartner__c);
}
}
List<Account> acclistupdate = new List<Account>();
for(Account acclist: [Select id,SalesPartner__c from account where id=:accwithspmap.keyset()]){
If(accwithspmap.containskey(acclist.id)){
acclist.SalesPartner__c = accwithspmap.get(acclist.id);
acclistupdate.add(acclist);
}
}
Update acclistupdate;
}
}
Please find the below explanation to the code.
The overall code is assing the Job salespartner to the Account salespartner field and wrote teh line by line explanation . Let me know if you face any issues.
If this solution helps, Please mark it as best answer.
Thanks,
Just Simple:-
if you need any assistanse, Please let me know!!
Kindly mark my solution as the best answer if it helps you.
Thanks
Mukesh