You need to sign in to do that
Don't have an account?
sinchana belliappa
Update Task field by using trigger
Hi all, I'm new to Salesforce Development.
I need to write a trigger on task object .
Requirement is whenever Opportunity Date field changes in opportunity it should populate on Task object Opportunity date field .any help would be appreciated
I need to write a trigger on task object .
Requirement is whenever Opportunity Date field changes in opportunity it should populate on Task object Opportunity date field .any help would be appreciated
It looks like our team of experts can help you in resolving this by explaining in step by step.
We have Salesforce global help-desk support and you can log a case and our Customer Success Agents will help you solve this issue. You can also speak to them on live chat. Click on the below link to contact our help-desk. Trust me it is a support service that we are offering for free!
https://jbshelpdesk.secure.force.com
Thanks,
Jarvis SFDC team
You need to write trigger on Opportunity as your requirement says that on Date field change on Opportunity, then task to create.
Your can try somthing as below:
trigger trigOpp on Opportunity (after update){
Set<Id> changeOppId = new Set<Id>();
List<Task> taskList = new List<Task>();
for(Opportunity opp : Trigger.new){
if(Trigger.oldMap.get(opp.Id).Date__c != Trigger.newMap.get(opp.Id).Date__c){
Task newTask = new Task();
newTask.whatId = opp.Id;
newTask.subject = 'Task'+opp.Name;
taskList.add(newTask);
}
}
insert taskList;
}
Share your thougths!
Thanks,
Sucharita
Your quick respone was helpfull to me.I modified the above trigger into the helper class and then called the method and it worked out.
Thank you,
Sinchana
Glad that it'll helped you. Please mark this answer as correct, so it can help other users also.
Thanks,
Sucharita