Monday, March 23, 2015

Task Trigger and Ugly Un-bulkfiication.

Problem

We had created a trigger on Case Task that would update a custom description field on the parent case with comment from the task when the status of the task changes to "closed."  This trigger worked at the beginning, but then this trigger started to fail with following error message:
Apex Task trigger cannot handle batch operations on recurring tasks.

It turns out that you cannot to have a trigger on event (including task) if you have any batch job on recurring events (see here) and that another team working with this client had implemented a batch apex job that managed recurring tasks related to some other object.  

Work-around

There really wasn't a work-around for this issue.  What we ended up doing was getting rid of the trigger and let user manually copy the value.

Takeaway

Trigger is one of the most problematic aspect of Salesforce.com development with many nuances, this being one of them.  With the release of the new Lightning Process Builder, we finally may have a work-around on this issue and many other trigger-related issues, although I cannot say that with high confidence as this very new feature with Salesforce.com.

No comments:

Post a Comment