You need to sign in to do that
Don't have an account?
BigP
Can someone explain this code and what its purpose?
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;
}
I hope, its clear.
Thanks!!
All Answers
Whenever Job record created with Account and Sales partner then Account record is updating with sales partner field value from Job__c record.
Thanks!!
I want to know the meaning of each line of the code because i am new to apex.
I hope, its clear.
Thanks!!