I am trying to figure out a way to run a "run if" action is a list item is created during non business days or hours. Our scenario is that we want something forwarded to someone else during after hours. Any help would be appreciated.
Solved! Go to Solution.
This will definitely be possible. I think you will have to calculate a few things before you get to the Run-if.
1. Calculate the date of the week. (Sat, Sun, Mon, Tue, Wed, Thu, Fri) (fn-FormatDate(DATEToCalcFrom,'ddd'))
2. Calculate the time of the day. (This will depend on your business hours, i.e. 8:00 - 17:00 - then you will have to get the current hour, i.e. 15 for 15h00).
3. At this stage I will add a parallel action. In branch 1. I will add a Run-if to test for Sat and Sun. In branch 2. I will test for Mon - Friday.
Inside the Run-if 1. you can add the assign flexi task to send the email because if it is SAT or SUN then it is after hours and you can send the email to the afterhours person. In the Run-if 2, I will add a second Run-if to test for the hours - Hours < start hours and Hours > ending hours. If this test is passed, I will copy the flexi task from branch 1 to this point to then send the email to the after hours support.
This should solve the problem.
Let me know if I need to explain it in more details.
Thanks so much for the help. I guess I do need a little more explanation on the calculate day of the week and time of the day portions. Sorry, I'm new to Nintex so trying to figure these things out!
A few Steps:
1. Create Variables DayofWeek as String, nrHoursofDay as Number and txtHoursofDay
2. Add Build String Action and add formula fn-FormatDate(startdate,ddd)) and save to DayofWeek - for today this will return 'THU'
3. Add Build String Action and add formula fn-FormatDate(startdate,hh)) and save to txtHourofDay - for now it will return '03' depending on your time settings on the server.
4.Convert the time to number from txthourofday to nrhoursofday. This will help with the Run if check.
Then you start with the Run if structure as described earlier.
In any conditional action, Set a Condition, Run If, Etc., You can use Inline Functions to support your calculations. So using the metadata from the item, I assume it is the Created date, you can use the Inline Function of FormatDate as Francoise demonstrates to get the day of the week. Once you have that, you can determine what actions to do next.
If it is better to not do the condition right away, you can store the day of the week into a variable using the Set Variable action still using the inline functions. Then with that variable, use if one or additional conditions further down the workflow.
This is working great for the day of the week. But it looks like my "run if" for hour of the day is not working properly. I suspect:
- There is a formatting issue with extracting the 2 digit hour from my date/time variable.
- My "run if" conditions are not correct.
I set up my build string/formula and my conversion just as you described. Our business hours are 8AM to 6PM, so my "run if" basically states if the hour is equal to or greater than 18 or if it is less than 8. Any ideas?
Thanks for the suggestions, but this particular workflow needs to be running at all times. Unless there is some way to separate the actions of one workflow over two different ones?
Just add a Log in history event and write the nrTimeofDay variable into the log in history. Then execute the workflow again. Once it completed go to the item, click on the droplist, select workflow and look at the value that was created for nrTimeofDay. It might be that your server is running on the non-military time, i.e. 01 - 12 and then 01 to 12 again with PM at the back. If this is the case you will have to get the AM or PM as well. Then in this case before running the Run-if on date add another run-if that checks for PM. If it is PM add a calculation that nrTimeofday = nrTimeofday + 12.
Let me know if this is not the case