
[vc_row row_type=”row” use_row_as_full_screen_section=”no” type=”full_width” text_align=”left” box_shadow_on_row=”no”][vc_column][vc_column_text]
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 that 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 a few date fields.
Issues: None.
Conclusion: This Custom formula field can now be used to notify when there are exactly ‘x’ business days from the required date field.
[evp_embed_video url=”http://www.infometryinc.com/wp-content/uploads/2019/02/Rohan_X_Business.mp4″
poster=”http://www.infometryinc.com/wp-content/uploads/2019/01/X-days.png” template=”mediaelement” width=”1060″ height=”795″ ]
[/vc_column_text][/vc_column][/vc_row]