You need to sign in to do that
Don't have an account?
raji devi 1
Trigger for update field depends on picklist values in solution object
Hi All,
Thanks in advance.
I have written a trigger on solution object Sample code below. Mysenariou islike this : we are saving the records in solution object defaulty the status field (picklist) value is Draft. When it changed to'Duplicate'then solution Detail (Rich Text Area) also update to 'Duplicate' ?
trigger solutiontest on Solution(after update){
set<id> solutionids= new set<id>();
for(solution s : trigger.new){
solutionids.add(s.id);
}
list<solution> slist =[select id,SolutionNote, status from solution where id in : solutionids];
for(Solution s : slist){
if(s.status == 'Duplicate'){
s.SolutionNote= s.status;
slist.add(s);
}
}
update slist;
}
Thanks and Regards,
Raji
Thanks in advance.
I have written a trigger on solution object Sample code below. Mysenariou islike this : we are saving the records in solution object defaulty the status field (picklist) value is Draft. When it changed to'Duplicate'then solution Detail (Rich Text Area) also update to 'Duplicate' ?
trigger solutiontest on Solution(after update){
set<id> solutionids= new set<id>();
for(solution s : trigger.new){
solutionids.add(s.id);
}
list<solution> slist =[select id,SolutionNote, status from solution where id in : solutionids];
for(Solution s : slist){
if(s.status == 'Duplicate'){
s.SolutionNote= s.status;
slist.add(s);
}
}
update slist;
}
Thanks and Regards,
Raji
Here is a basic concet that if you are update the field of same object on which you writing trigger then use Before Update instead of After Update.
Use the below code.
Let me know if it helps you out.
Peace.
All Answers
Here is a basic concet that if you are update the field of same object on which you writing trigger then use Before Update instead of After Update.
Use the below code.
Let me know if it helps you out.
Peace.
I thing you should need to write the trigger on before update so that you do not need to again update so "slist" that solution list.
Try this code if you any issue plz let me know.
Thanks.
Thanks alot , Naresh and Rohit
Regards,
Raji