You need to sign in to do that
Don't have an account?
Akash Choudhary 17
Want to update contact's description if opportunity Description is updated
Hi all ,
This is my code , I want to update Contact's description everytime I update opportunity's description.
This is not working somehow . please help me figure out my mistake
public class DESC_UpdateForum {
public static void DESC_UpdateForumMethod (list<Opportunity> Opplist){
Set<Id> idSet = new set<Id>();
For(Opportunity Opp : Opplist){
if(Opp.AccountId != null){
idset.add(Opp.AccountId);
}
}
List <Contact> con = [SELECT Id,
AccountId,
Description
From Contact
Where AccountId IN :idSet];
Map<Id , String> Oppmap = new Map<Id, String>();
For(Opportunity Opp : Opplist){
If(Opp.Account != null){
Oppmap.put(Opp.AccountId , Opp.Description);
}
}
if(con.size()>0){
For(Contact c :con){
If(c.AccountId != null){
c.Description = Oppmap.get(c.AccountId);
}}
}
Update con;
}}
Thanks
This is my code , I want to update Contact's description everytime I update opportunity's description.
This is not working somehow . please help me figure out my mistake
public class DESC_UpdateForum {
public static void DESC_UpdateForumMethod (list<Opportunity> Opplist){
Set<Id> idSet = new set<Id>();
For(Opportunity Opp : Opplist){
if(Opp.AccountId != null){
idset.add(Opp.AccountId);
}
}
List <Contact> con = [SELECT Id,
AccountId,
Description
From Contact
Where AccountId IN :idSet];
Map<Id , String> Oppmap = new Map<Id, String>();
For(Opportunity Opp : Opplist){
If(Opp.Account != null){
Oppmap.put(Opp.AccountId , Opp.Description);
}
}
if(con.size()>0){
For(Contact c :con){
If(c.AccountId != null){
c.Description = Oppmap.get(c.AccountId);
}}
}
Update con;
}}
Thanks
Yes this is after update and this was not a dumb question .
Please try the below code:
If you found this answer helpful then please mark it as best answer so it can help others.
Thanks
Akshay