- General Development
- Schema Development
- Apex Code Development
- Visualforce Development
- Formulas & Validation Rules
- Force.com Sites & Site.com
- Chatter Development
- Java Development
- .NET Development
- Perl, PHP, Python & Ruby
- Desktop Integration
- APIs and Integrations
- Visual Workflow
- Apple, Mac and OS X
- VB and Office Development
- AppExchange Directory & Packaging
- Salesforce Labs & Open Source Projects
- Other Salesforce Applications
- Jobs Board
11-06-2012 05:47 AM
I'm having a hard time with workflow rules running on weekends and holidays. I really wished that Salesforce had the option to only account business days instead of calendar days.
I'm trying to workaround this limitation, and I have two formulas:
One for returning the day of the week:
MOD(TODAY() - DATE(1900, 1, 7), 7)
This will return a number from 0 to 6 (0 = Sun, 6 = Sat), which you could use to trigger the WFR accordingly
Other to check if today is a given holiday:
today() = datevalue(2012-12-25),
today() = datevalue(2012-12-26)
I'd like to "merge" these two formulas, how can I do that? It would be a formula that checks if current day is different from Sunday and Saturday, AND diferent from one of the holidays, and return "Yes" or "No" to the "Is Business Day?" question.
Any help is appreciated!
Thanks in advance!
11-07-2012 03:14 PM
I think this is what you're looking for:
IF( AND( /* Check for weekday */ AND( MOD( TODAY() - DATE( 1900, 1, 7 ), 7 ) > 0, MOD( TODAY() - DATE( 1900, 1, 7 ), 7 ) < 6 ), /* Check for known holiday */ NOT( OR( TODAY() = DATE( 2012, 12, 25 ), TODAY() = DATE( 2012, 12, 26 ) ) ) ) , "Business as usual", "No work today!")
The first part checks that the modulus is between 1 and 5, and the second part checks that the date doesn't fall on one of the known holidays. It only evaluates to true if both are true.
Senior Product Manager, Declarative Apps