You need to sign in to do that
Don't have an account?

Help to reduce formula field compiled size
Am trying to calculate remaining response time for the case.
Based on the priority of the case we are setting the remaining time to respond the case(in hours and mins).
Please see http://salesforce.stackexchange.com/questions/153040/case-response-time-calculation-in-formula-field/153046?noredirect=1#comment224405_153046 for scenario description.
Important thing is, we need to show the remaining time dynamically. That is, when the page is refreshed after 10 min, it should change the remaining time dynamically.
So went for the formula field to calculate. Here is my formula,
caseOwnerChanged__c - Checkbox field, which returns true if owner changed. When the case owner changes, response time should stop wherever it is.
ResponseTime__c - formula field which returns 30 for P1, 120 for P2, 480 for P3...
caseOwnerChangedOn__c - Returns datetime when owner changed
So, am trying to save this formula but am getting
I tried putting the formula's
So, Any other way to simplify this formula?.
Based on the priority of the case we are setting the remaining time to respond the case(in hours and mins).
Please see http://salesforce.stackexchange.com/questions/153040/case-response-time-calculation-in-formula-field/153046?noredirect=1#comment224405_153046 for scenario description.
Important thing is, we need to show the remaining time dynamically. That is, when the page is refreshed after 10 min, it should change the remaining time dynamically.
So went for the formula field to calculate. Here is my formula,
IF( caseOwnerChanged__c , IF(FLOOR((((CreatedDate + ( ResponseTime__c /1440 )) - caseOwnerChangedOn__c ) * 24 * 60) / 60) = 0, LEFT( TEXT(MOD((((CreatedDate + ( ResponseTime__c /1440 )) - caseOwnerChangedOn__c ) * 24 * 60) ,60)),2 ) &' min', (TEXT(FLOOR((((CreatedDate + ( ResponseTime__c /1440 )) - caseOwnerChangedOn__c ) * 24 * 60) / 60)) &' hr'& LEFT( TEXT(ABS(MOD((((CreatedDate + ( ResponseTime__c /1440 )) - caseOwnerChangedOn__c ) * 24 * 60) ,60))),2 ) &' min') ), IF(FLOOR((((CreatedDate + ( ResponseTime__c /1440 )) - NOW() ) * 24 * 60) / 60) = 0, LEFT( TEXT(MOD((((CreatedDate + ( ResponseTime__c /1440 )) - NOW() ) * 24 * 60) ,60)),2 ) &' min', (TEXT(FLOOR((((CreatedDate + ( ResponseTime__c /1440 )) - NOW() ) * 24 * 60) / 60)) &' hr '& LEFT( TEXT(ABS(MOD((((CreatedDate + ( ResponseTime__c /1440 )) - NOW() ) * 24 * 60) ,60))),2 ) &' min') ) )
caseOwnerChanged__c - Checkbox field, which returns true if owner changed. When the case owner changes, response time should stop wherever it is.
ResponseTime__c - formula field which returns 30 for P1, 120 for P2, 480 for P3...
caseOwnerChangedOn__c - Returns datetime when owner changed
So, am trying to save this formula but am getting
Error: Compiled formula is too big to execute (9,018 characters). Maximum size is 5,000 characters
I tried putting the formula's
- (((CreatedDate + ( ResponseTime__c /1440 )) - caseOwnerChangedOn__c ) * 24 * 60)
- TEXT(MOD((((CreatedDate + ( ResponseTime__c /1440 )) - caseOwnerChangedOn__c ) * 24 * 60)
So, Any other way to simplify this formula?.
If you are blocked by the limit size for this formula and given that this value is just used in a page, you can transform the formula in apex and used the new calculated field in a visualforce page containing just one field.
Floor and Mod exist in the class Math, the rest is just string formatting (class String)
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_methods_system_math.htm
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_methods_system_string.htm
Regards.
The translation in Apex seems fully automatic. This is an example of the class helper that you need to call with caseOwnerChangedOn__c or Date.now().getTime()
String.left(2) should be replaced in Apex but that is exactly what it is done by the formula basically.
As soon as you have the good result in Apex, the associated visual page is the easiest part
Alain
Thank you very much for your interest in my question. I've did the same thing to show the field in visualforce page. Now i need to send an email Alert to case owner when the time reaches the count 0. I don't know how to get the count on the fly and send email. You have any suggestions
1) There is a PDF of Salesforce of Tips for Reducing Formula Size
Interesting but the first problem here is a big number of calls to functions ( FLOOR TEXT LEFT ... ) and there is not a solution by formula.
https://resources.docs.salesforce.com/204/latest/en-us/sfdc/pdf/salesforce_formula_size_tipsheet.pdf
2) "send an email Alert to case owner when the time reaches the count 0": you need a daily batch (+ an updated flag in the case ideally).
When the time reaches the count 0, there is no external event (no data change in the case) and the processes/workflows need a data change or a fix delay from a stored date for their scheduled jobs (the time which reaches the count 0 is not stored here). Otherwise you store a new calculated date (due date) and you can use it it for automatic scheduled processes.
Every night, a schedule batch reads all the cases (not flagged), calculates if a time reaches to count 0 for every read case and send the emails and finally, updates the flag "email_sended" (if it could be resend the next day).
3) You can define rules that trigger Time-Based Workflow actions off of any date or date/time field on the Object.
https://help.salesforce.com/articleView?id=000005245&type=1
The principle is simple: When salesforce.com triggers a workflow rule, its time-dependent actions are placed in the workflow queue.
setup > Monitor > Time-Based Workflow