My Account | Internet Creations
Welcome, Guest.

Sort Case Flags by Color vs. Age


By default, flags will be sorted in list views based on the amount of time that has elapsed since the flag was set. For organizations utilizing multiple sets of flag aging processes, users may notice higher level flags (such as Red and Black) mixed in with lower level flags (such as Blue and Yellow). In certain instances, it may be more desirable to sort flags based directly on their color vs. the age.


One way to accomplish this would be to create a custom formula field on the case object. To do so, please follow the steps outlined below.

1. Navigate to Setup > Customize > Cases > Fields.
2. Click the field label for Flag or Flag BH depending upon if your organization uses Business Hours, and copy the formula.
3. Navigate back to the previous page, and click the New button under Case Custom Fields & Relationships.
4. Select Formula as the Data Type and click Next
5. Specify a Name / Label for your new field, and select Text as the return type.
6. Paste in the formula copied earlier as the formula for your new field, and adjust all instances of flagsort=" with flagsort=1,2,3 or 4.
For example:

flagsort=" & FLAGS__Case_Flag_Age_Text__c & "&file=" & $Setup.FLAGS__FlagPref__c.FLAGS__Offset4Image__c, "L4", 16, 16)

would need to be adjusted to
flagsort=4" & FLAGS__Case_Flag_Age_Text__c & "&file=" & $Setup.FLAGS__FlagPref__c.FLAGS__Offset4Image__c, "L4", 16, 16)

7. Once the formula is solidified, click Check Syntax to ensure there are no errors and click Next.
8. Establish Field Level Security for the profiles in your organization and click Next
9. Select which Page Layouts you want to add the field to. If you're looking to simply use this field in Case List Views, consider deselecting all page layouts on this screen, and click Save.
10. Once the field has been successfully created, navigate back to the Cases tab.
11. Open up each List View, swap in your newly created field and remove the packaged field previously being used.
12. Test each List View by sorting on the new field to ensure the new sorting methodology is working as expected.

If you wish to use a sample formula provided by Internet Creations, where the Flags will be displayed by color, where the order is L4 (top), L3, L2, L1 (bottom), and within each level, they will show the oldest at the top and the newest at the bottom, you can refer to the following:
IF(ISNULL(FLAGS__ViewedFlag__c),null, IF(FLAGS__Case_Flag_Business_Age__c > (IF(ISBLANK(FLAGS__CaseTimeOffset4__c), $Setup.FLAGS__FlagPref__c.FLAGS__TimeOffset4__c,FLAGS__CaseTimeOffset4__c)), IMAGE( "/servlet/servlet.FileDownload?flagsort=L4" & LPAD(TEXT(86400 * (DATETIMEVALUE("9999-12-31 23:59:59")-FLAGS__CaseFlagsEscalationTime4__c)),12,"0") & "&file=" & $Setup.FLAGS__FlagPref__c.FLAGS__Offset4Image__c, "L4", 16, 16), IF(FLAGS__Case_Flag_Business_Age__c >= (IF(ISBLANK(FLAGS__CaseTimeOffset3__c), $Setup.FLAGS__FlagPref__c.FLAGS__TimeOffset3__c,FLAGS__CaseTimeOffset3__c)), IMAGE( "/servlet/servlet.FileDownload?flagsort=L3" & LPAD(TEXT(86400 * (DATETIMEVALUE("9999-12-31 23:59:59")-FLAGS__CaseFlagsEscalationTime4__c)),12,"0") & "&file=" & $Setup.FLAGS__FlagPref__c.FLAGS__Offset3Image__c, "L3", 16, 16), IF(FLAGS__Case_Flag_Business_Age__c >= (IF(ISBLANK(FLAGS__CaseTimeOffset2__c), $Setup.FLAGS__FlagPref__c.FLAGS__TimeOffset2__c,FLAGS__CaseTimeOffset2__c)), IMAGE( "/servlet/servlet.FileDownload?flagsort=L2" & LPAD(TEXT(86400 * (DATETIMEVALUE("9999-12-31 23:59:59")-FLAGS__CaseFlagsEscalationTime3__c)),12,"0") & "&file=" & $Setup.FLAGS__FlagPref__c.FLAGS__Offset2Image__c, "L2", 16, 16), IF(FLAGS__Case_Flag_Business_Age__c >= (IF(ISBLANK(FLAGS__CaseTimeOffset1__c), $Setup.FLAGS__FlagPref__c.FLAGS__TimeOffset1__c,FLAGS__CaseTimeOffset1__c)), IMAGE( "/servlet/servlet.FileDownload?flagsort=L1" & LPAD(TEXT(86400 * (DATETIMEVALUE("9999-12-31 23:59:59")-FLAGS__CaseFlagsEscalationTime2__c)),12,"0") & "&file=" & $Setup.FLAGS__FlagPref__c.FLAGS__Offset1Image__c, "L1",16,16), IMAGE( "/servlet/servlet.FileDownload?flagsort=L0" & LPAD(TEXT(86400 * (DATETIMEVALUE("9999-12-31 23:59:59")-FLAGS__CaseFlagsEscalationTime1__c)),12,"0") & "&file=" & $Setup.FLAGS__FlagPref__c.FLAGS__BlankOffsetImage__c, "L0",16,16) )))))

Please note:  This KB article is provided as-is and creating custom fields outside of the Case Flags package is not supported. For further assistance, please contact your Salesforce administrator, Salesforce implementation partner, or your Internet Creations Account Executive to inquire about professional services. 


Open a Case