Skip to main content

Hello everyone,

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.

Thanks!

William

Hi William,

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.


Hi Francois,

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!

Thanks!

William


No Problem

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.


Hi Francois,

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.

or

- 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?

1.JPG

3.JPG

4.JPG

2.JPG


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?


Thanks for the help. The day of the week if working fine for me thanks to the suggestions. Just having issues with the time of day now.


Hi William,

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


Sorry, I should have added this...to get the AM or PM you will have to use fn-FormatDate(startdate,tt)


Hi William, not sure if you found your solution to this but there is a way to use the Run If on weekdays by checking if the specified date begins with "S":

Condition: If any value equals value
Value: fn-FormatDate(DATE,dddd)

   does not begin with
Value: S

As for the time can you use the Run If with an AND, format the date to output the time only then use greater than less than functions (e.g. assuming your business hours are 9am to 5pm):

Condition: If any value equals value
Value: fn-FormatDate(DATE,HHmm)

   greater than or equal to
Value: 0900

AND

Condition: If any value equals value

Value: fn-FormatDate(DATE,HHmm)

   less than or equal to
Value: 1700

Using the correct combination of AND/OR's you should be able to execute all 3 conditions in a single Run If action.


Reply