Hi Community,
I have one process that runs at every half an hour between 3am to 7am and I need to check if at the last run of the process if the job is in processing state I have to send the mail stating the same.
How to do it??
Can anyone help?
Hi @Kunal_Jain
You can create a different process to run, consume the orchestrator API to get the state of your jobs, based on that you can send the email with the state
UiPath Orchestrator API Guide.
https://docs.uipath.com/orchestrator/reference/jobs-requests
Regards!
How to and where to use the code?
Create a new process, just install the UiPath.webapi activities to consume the API based on the documentation i shared above, it would be a normal sequence with all the validations
Here are some examples how to
Regards
Ideally last run would be at 7…and when bot is running it will be in processing state only…so you can check the time in your bot if it crossed 7 and send the email…
But I guess your requirement is something more…can you elaborate
Cheers
Actually Last run is not exactly at 7 but it will be after 7 so need to check just the last run and if it is in last run state and job is still processing than need to send the mail.
Check the start time of the job in your initialize state…if start time is greater than your end time(7)…then its the last run…
and when you mean processing i believe you mean going into process xaml…use a boolean to check if process xaml is invoked or not…now…use the time saved in initialize state and the boolean variable value combination to know if this is last run and if it is processing or not
Hope this helps
cheers
Actually Processing means the job on portal is processing.
The logic for getting the start time remains same…as per whatever processing that you want to check …do that check only when the start time of job is greater than 7 AM for your case…and send email only then…if start item is less than the 7AM then do not send
Hope this is clear
cheers
No .
What we are doing is the bot is checking the portal every half an hour for the same job and if the job is in processing state then we will again check the job after half an hour.
But if it is the last run that is 7 o clock run and job is still in processing state than only we need to send the mail.
In the initialize state create a starttime varaible of date time and assign Now to it at the start right before your initialize settings.xaml…in the initialize state itself…
Now after checking the processing state of the job in your process.xaml or any other xaml…use a if condition…and use StartTime.hour >= 7
and job is in processing (Include this condition also)…then on the then side send email…so that email would be sent only after 7 and if job is in processing
you can as well use StartTime.hour = 7
but just for safe keeping added greater than as well
cheers
But if the last process is at 7 and it ends in 7:30 than it will not send the mail if the job is in processing state also.
What about that case??
Why would it not…because you are saving the start time…whenever it ends start time will still be 7 only…so even if it ends at 8 …still satrttime.hour will be 7 only and our condition will work…Please try it…
cheers