Showing posts with label trigger. Show all posts
Showing posts with label trigger. Show all posts

Monday, May 18, 2015

Forecasting Quota and Risk of Salesforce Upgrade


Problem

This is a bit of old problem, but we had this custom Visualforce interface in our internal org that allows you to mass insert and edit Forecast Quota.  This has been working fine for years, but when we tried to enter forecast for this year, we suddenly got this error:

Missing Required Field: [Quota Quantity]
However, when we tried to modify the code to allow manual entering of quota, we were getting error indicating that this field is not writable.


Solution

What turned out happen was that you need to have ForecastingType set if you are using ForecastingQuota inside of code after API v28.  Once we enabled a revenue forecast on opportunity (Setup > Customize > Forecasts > Setting), the interface worked again.

Takeaway

This was another lesson on using custom code with Salesforce (especially something that interacts with Standard feature, such as Standard object) and Salesforce upgrade.  Writing custom code can certainly improve the usability of Salesforce, and I do believe it to be one of major feature of Salesforce, but one has to be mindful that it can suddenly get broken without warning.  This is one of the reason why Salesforce recommends using as much of standard functionality as possible (70 to 80% standard functionality is the Salesforce benchmark).

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.