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
Mauricio OliveiraMauricio Oliveira 

Dated default values + email alert

Hi there,

I need some Quote fields to have a default value, that would be updated probably in a monthly basis (basically "dated default values"). Also, ideally they should be non-editable fields, but there will be exceptions, so I'm thinking of not letting them locked for edition but rather fire some email alert to key managers warning about the edition (I've never used approval processes, not sure how they work).

So, which would be the best approach for this use case?

My first thought: Since those default values will be dated, I was thinking of creating a custom object "DatedDefaultValue" with FieldName__c, DefaultValue__c, StartDate__c and populate Quotes with a trigger on creation, and using either ISCHANGED() formulas in Workflow Rules + Email Alert or even using update triggers to warn about changes. In this approach my concern is about SOQL limits :(. By having a custom object for this (instead of using field's default value mechanism) I wouldn't lose information about previous default values.

What do you guys think? Is there any other suggestion or more common approach for this use case?

​Thanks in advance.
Shashikant SharmaShashikant Sharma
Hi Mauricio,

I think you could go ahead with the approach. You will not face any Governor Limit for SOQL as you could bulkify your trigger.

Read this: https://developer.salesforce.com/page/Best_Practice%3A_Bulkify_Your_Code

So instead of Querying the custom object every time for record you could query all records in one SOQL.

I would suggest you start with your approach if you face any issues then you could post questions.

Thanks
Shashikant
Mauricio OliveiraMauricio Oliveira
Hi Shashikant,

Thank you for the reply. I'm aware of bulkifying triggers, but my concern is that I have a lot of logic using triggers already (specially quotes), I already had to make some big refactorings to avoid hitting limits during tests, so I always avoid adding any kind of logic using triggers from now on. That is why I'm asking if there is any other good approach besides that.

If anyone can contribute with another idea or additional tips it would be great.