0

I'm using the following formula in order to show color coding:

enter image description here

And the content of CS_CaseAge__c are as:

IF(ISNULL(ClosedDate), (FLOOR(( NOW()- CreatedDate)*24)) + ROUND(((( ((Now() - CreatedDate)*24)- FLOOR((Now() - CreatedDate)*24)) *60)/100),2), (FLOOR(( ClosedDate- CreatedDate)*24)) + ROUND(((( ((ClosedDate - CreatedDate)*24)- FLOOR((ClosedDate - CreatedDate)*24)) *60)/100),2))

Do we need to perform the above operation in a different manner? If so what it should be otherwise let me know how I may reduce to 5,000 characters limit.

EDIT: Formula used

IF(CS_CaseAge__c>0 && CS_CaseAge__c<=12, IMAGE('/resource/CS_GreenIMG', "green", 20, 50), IF(CS_CaseAge__c>12 && CS_CaseAge__c<=50, IMAGE('/resource/CS_YellowIMG', "yellow", 20, 50), IF(CS_CaseAge__c>24, IMAGE('resource/CS_RedIMG', "red", 20, 50), IMAGE('resource/CS_RedIMG', "red", 20, 50))))

4
  • Could you post the formula rather than including a picture of it? It will be easier for people to provide answers by copying and pasting the code. Thanks – BarCotter Feb 13 '15 at 10:31
  • Please see the edits. – sanchit Feb 13 '15 at 10:55
  • Is the logic supposed to be 0 - 12 = green image, 13 - 24 = yellow image, 25 and above = red? You have it as 0 - 12 = green image, 13 - 50 = yellow image, 25 and above = red. Its not clear what the 25 to 50 range should be. – BarCotter Feb 13 '15 at 10:57
  • Absolutely right, this is the problem statement I want to achieve using formula. – sanchit Feb 13 '15 at 11:00
1

If you are looking to achieve the requirement below then you could consider rewriting your logic so that CS_CaseAge__c isn't used as much.

0 - 12 = green image, 13 - 24 = yellow image, 25 and above = red

If you use the logic below then you will only be calling CS_CaseAge__c 3 times (instead of 5) in total and will achieve the exact same thing.

if (CaseAge >= 25) red
if (CaseAge >= 13) yellow
if (CaseAge >= 0) green
else red

Here's how the updated formula would look

IF(CS_CaseAge__c >= 25, IMAGE('resource/CS_RedIMG', "red", 20, 50),
IF(CS_CaseAge__c >= 13, IMAGE('resource/CS_YellowIMG', "yellow", 20, 50),
IF(CS_CaseAge__c >= 0, IMAGE('resource/CS_GreenIMG', "green", 20, 50),
IMAGE('resource/CS_RedIMG', "red", 20, 50))))

I personally would of written it something like this so that there is only two calls to CS_CaseAge__c but this would mean if CS_CaseAge__c is negative (which is probably never going to happen) the green image would appear.

IF(CS_CaseAge__c >= 25, IMAGE('resource/CS_RedIMG', "red", 20, 50),
IF(CS_CaseAge__c >= 13, IMAGE('resource/CS_YellowIMG', "yellow", 20, 50),
IMAGE('resource/CS_GreenIMG', "green", 20, 50)))
1
  • 1
    It worked like charm :) Thanks @BarCotter But I need to test its validations as well. – sanchit Feb 13 '15 at 11:24
1

The formula is too large according to the error message. The following PDF gives tips to reduce formula size. You have only a few characters extra.

Tips for Reducing Formula Size

Alternatively, you can use Workflow and field update to update the field accordingly. Another method is to write a trigger for the same.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.