You need to sign in to do that
Don't have an account?
Anne Clisham 7
Trigger creating more than one Task
I am using a trigger to create a task on an Account record. The task should be created when a "notice" date on the account equals today's date. I have the trigger working but every time I edit the account, it creates another task. I only want one task for when the date criteria is met. The notice date will change to a future date so the process will start all over once the new notice date equals today. I read a few of the posts but I am not seeing something that matches what I am trying to do. I am an admin but working to get more involved with developing. Thanks for any help.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | trigger WaiveTaskCreate on Account (after update) { for (Account acct : Trigger.new){ if(acct.Date_Notice__c==System.Today()){ Task t = new Task(); t.Subject = 'Subject'; t.OwnerID = acct.OwnerID; t.Priority = 'High'; t.Description = 'Comment'; t.WhatID = acct.Id; t.ActivityDate = (acct.Exp_Date__c + 15); insert t; } } } |
You can try this - Pls, let me know if it helps you.
Thanks,
Sumit Kumar Singh
Never perform dml operation inside loop.
Try this!
Why are you writing trigger for this, the best way to resolve this is to use Time Based Workflows. As it will not create multiple task when you update the Account and accordingly create new task when the Notice Date is changed.
Try using the Time based workflows and if you face any issue or need assistance, please let me know.
Thanks,
Neetu