Searching Picklist, Multi-Picklist, and Date Values from Global Search and List View Search in Salesforce
January 21, 2019Identify a Date in Salesforce
Problem Description: Salesforce customers/users find it hard to count business days between today and a particular date as there is no function/method which lets you know the number of business days between two dates. So, if a user wants to get notified when there are exactly ‘x’ business days left before a particular date, there is no straightforward way of achieving it.
Challenges to User/Developer : A Suggested workaround is to create a formula field that holds a date which is exactly ‘x’ business days away from a particular date.
Solution :
Approach : Use WEEKDAY() function to get values 1,7,2 depending on the date added inside the function.
Technical Solution :
Create a custom field to hold the date which is ‘x’ business days from a particular date.
WEEKDAY(date field) returns the day of the week for the given date, using 1 for Sunday, 2 for Monday, through 7 for Saturday. Below is the formula.
CASE(WEEKDAY(Agreed_Due_Date__c),1, Agreed_Due_Date__c – 6,7,Agreed_Due_Date__c – 5,Agreed_Due_Date__c – 7) |
In the above example ‘x’ is 5.This formula field counts 5 business days before a date field “Agrees_Due_Date”.
Advantage : Easy to migrate, Not hard to implement, Scalable when business days have to be calculated for few date fields.
Issues : None.
Conclusion : This Custom formula field can now be used to notify when there is exactly ‘x’ business days from the required date field.