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
KyriacosKyriacos 

Would a formula or trigger be better?

I have been working on a formula but I cannot make it without exceeding the compile limit. Shown below if a fraction of the formula. Do you know how I could reduce the compile size? Or do you know if a trigger would be better to use? If so, could you give me an example of how to get that trigger started??

 

I don't believe CASE can be used because the outcome depends on the value in two different fields. Please correct me if I am wrong.

 

IF(
AND( CONTAINS(Domain__c,"DK") , Account_Balance__c < 500),
"Prize Draw",
IF(AND(CONTAINS(Domain__c,"DK"), Account_Balance__c < 2000,Account_Balance__c > 499 ),
"25",
IF(AND(CONTAINS(Domain__c,"DK"), Account_Balance__c < 5000,Account_Balance__c > 1999 ),
"50",
IF(AND(Domain__c = "COM BR", Account_Balance__c < 3000,Account_Balance__c > 599 ),
"Prize Draw",
IF(AND(Domain__c = "COM BR", Account_Balance__c < 15000,Account_Balance__c > 2999 ),
"15",
"No Prize")))))


Best Answer chosen by Admin (Salesforce Developers) 
goabhigogoabhigo

Instead of trigger you can go for workflow field update. Use the same formula. But here the field should not be a formula field, can be a text field (you can make it read only through page layout).

All Answers

goabhigogoabhigo

Instead of trigger you can go for workflow field update. Use the same formula. But here the field should not be a formula field, can be a text field (you can make it read only through page layout).

This was selected as the best answer
KyriacosKyriacos

Would I not have the same compile limitations?

goabhigogoabhigo

Nope, workflow field update formula has more characters allowed.

KyriacosKyriacos

Perfect, I'll give that a try.