function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Uday KUday K 

Task Trigger

Hello All,

 

Can anyone give idea how to achieve the below requirement?

I have Policy Custom Object, Which is related to Account. There is a "renewal due date" field in Policy Object. Now i have to create a task on the Renewal Due Date. There could be many policies for an Account. Now we have to check that is there any policies with same Renewal Date related to one Account. We want to create only one task for the Policies with same Date.

 

Awaiting for early response.

Thanks,

Uday

goabhigogoabhigo

Here are few points which I think can help you:

  • Create a field in Policy - Task created
  • Write a before insert, before update trigger on Policy which checks whether Renewal Due Date is filled AND Task Created checkbox is not true
  • Retrieve the list of all Policies under the account - you can get Account ID from current trigger, query against all Policy records
  • Iterate through this list of Policies. Check whether Renewal Due Date of all the records matches with current record in trigger
  • If no, create a new task record, add it to a list of task. Mark the Task Created field as true
  • Before closing the trigger OR after all for loops insert the list of tasks

Does this help?

dev.Pinkydev.Pinky

Hi can you give code sample?? Iam also facing similiar issue..why dont we go for set??