I need some help to create an expression rule to check if my given time is within the range. For example, my process model will start running today at 6PM then should stop running at 5AM the next day. Now I need to create a validation where it returns true/false to check if the execution time is still within the range. Hope anyone could help me. Thank you.
Discussion posts and replies are publicly visible
What exactly is your question? How to check the date, that would be "start >= date <= end"? Or is it about starting your process? What exactly do you mean with "start running today at 6PM then should stop running at 5AM the next day"?
In general it is a best practice to just start processes in a certain interval and then have a XOR to check whether this exact moment in time is valid or not. But this depends on your actual use case.
I have a process model to run batch process which automatically triggers at 6PM today and should only run until 5AM the next day. It's looping it's own to collect another data before submitting it to the subprocess model. Now my question is, how to form a script that returns true/false to check if the execution time is still within the time range which is 6PM today until 5AM the next day. So the next time my process model calls itself again and it 5:01 AM, it should proceed on the end node.
Hope I made it clear. Thank you for your time.
Did you try to add a XOR gateway using a condition of "now() > pv!endDate"? I simple date comparison evaluates to your desired true/false.
Now, your can calculate the endDate using the a!addDateTime() function in the initial start and pass it along to the next calls.
Agree with Stefan.. When you are looping to restart the execution just put an XOR gate and check the time. If it's more than 5am, end the process
Hi Stefan, yes I have an xor to check, I am just having trouble with my logic how to create that script. However, I came up with this. I am not exactly sure if the logic is good enough. So my process model automatically runs at 6PM. So my xor will check if the time now is already 5AM. The logic here is I just need to find a way to tell the PM to stop. Then my process model will start running again at 6PM the next day and will end 5AM the day after.
a!localVariables( local!dateTime: right(text(ri!timeNow,"hh:mm AM/PM"),2), local!castTime: cast(8, local(ri!timeNow)), if( local!dateTime = "AM", local!castTime < totime("5:00 AM"), local!castTime > totime("5:00 AM") ) )
If you have any better input than what I have made, I'll be more than glad to take a look. Thank you.
This logic seems to be over-complicated. But before diving into this, can you share a screenshot of your process model?
Hello there, I already have the XOR my problem is how to put a logic where the xor will redirect to end node if the time is beyond 5AM. If I use the logic now() > totime("5:00 AM") and the time is 12:00 AM onwards, then 12:00 AM > 5:00 AM is false which will lead to ending the process model early than the expected time limit. I came up with this script instead. I am just not confident with the logic if it's appropriate
Below is my process model.
Then inside my xor can run, I have an expression with the code below:
= and( rule!SPM_IsProcessEnabled(pmUUID: pm!uuid), rule!DAO_ToRunHistoricalProfileDeletion(timeNow: now()) )
can you use something like this?
localvariable( local!currentTime: now(), local!finalTime:time(5,0,0,0), timevalue(local!currentTime)<local!finalTime )
That model seems to be OK. I think you should really calculate the desired end time when starting the process. Something like
now() + intervalds(11, 0, 0)
or
a!localVariables( local!tomorrow: today() + 1, datetime( year(local!tomorrow), month(local!tomorrow), day(local!tomorrow), 5, 0, 0 ) )
and store this in a PV and pass it along to the next iterations. Then your logic is just to compare now() vs. that.