If current date 8:15:00 a.m.<=now<= current date 8:45:00 a.m., then set variable to “1st Trigger”;
If current date 12:15:00 p.m.<=now<= current date 8:45:00 p.m., then set variable to “2nd Trigger”;
If current date 16:30:00 p.m.<=now<= current date 16:55:00 p.m., then set variable to “3rd Trigger”;
How to use VB to show above condition?
And I want to use a general variable [Like “Trigger”] which contains these 3 triggers for next move,
like:
If Trigger=“1st Trigger”, then…
If Trigger=“2nd Trigger”, then…
If Trigger=“3rd Trigger”, then…
Dim currentTime As DateTime = DateTime.Now
Dim Trigger As String = ""
If currentTime.TimeOfDay >= New TimeSpan(8, 15, 0) AndAlso currentTime.TimeOfDay <= New TimeSpan(8, 45, 0) Then
Trigger = "1st Trigger"
ElseIf currentTime.TimeOfDay >= New TimeSpan(12, 15, 0) AndAlso currentTime.TimeOfDay <= New TimeSpan(20, 45, 0) Then
Trigger = "2nd Trigger"
ElseIf currentTime.TimeOfDay >= New TimeSpan(16, 30, 0) AndAlso currentTime.TimeOfDay <= New TimeSpan(16, 55, 0) Then
Trigger = "3rd Trigger"
Else
Trigger = "No Trigger"
End If
' Set the out argument for Trigger
out_Trigger = Trigger
If trigger=“1st Trigger”, I should input “15.05.2024” to “16.05.2024” in below SAP column;
If trigger=“2ndTrigger” or “3rd Trigger”, I should input “16.05.2024” to “16.05.2024” in below SAP column
Do you know if any time VB coding can make it happen?
Dim currentTime As DateTime = DateTime.Now
Dim Trigger As String = ""
Dim StartDate As String = ""
Dim EndDate As String = ""
Dim today As DateTime = DateTime.Today
If currentTime.TimeOfDay >= New TimeSpan(8, 15, 0) AndAlso currentTime.TimeOfDay <= New TimeSpan(8, 45, 0) Then
Trigger = "1st Trigger"
StartDate = today.ToString("dd.MM.yyyy")
EndDate = today.AddDays(1).ToString("dd.MM.yyyy")
ElseIf currentTime.TimeOfDay >= New TimeSpan(12, 15, 0) AndAlso currentTime.TimeOfDay <= New TimeSpan(20, 45, 0) Then
Trigger = "2nd Trigger"
StartDate = today.ToString("dd.MM.yyyy")
EndDate = today.ToString("dd.MM.yyyy")
ElseIf currentTime.TimeOfDay >= New TimeSpan(16, 30, 0) AndAlso currentTime.TimeOfDay <= New TimeSpan(16, 55, 0) Then
Trigger = "3rd Trigger"
StartDate = today.ToString("dd.MM.yyyy")
EndDate = today.ToString("dd.MM.yyyy")
End If
' Set the out arguments for Trigger, StartDate, and EndDate
out_Trigger = Trigger
out_StartDate = StartDate
out_EndDate = EndDate
I might not read between the lines correctly here, but if by 1st trigger, 2nd trigger etc you mean which orchestrator trigger started the job, there is an easier way then messing around with needless code. (low-code platform right?)
Add an argument to your main.xaml. Just make it a simple string called ‘s_TriggerNumber’ for example.
Now, once this package is deployed and linked to a process, you can add the value for this argument in the orchestrator. In this case add it to your trigger, and setit there.
Now you might want to create 3 separate triggers, one for each case, and match the argument accordingly.
Your robot will then have runtime access to the ‘trigger #’ without reverting to scripting.
@lrtetala Sorry for the late response. I am runing debug this afternoon with your detailed solution. It should be working now. Thank you for the guidance. By the way, may I know how you can screenshot a long UiPath sequence? Usually I have to screenshot 2-3 times when I have a long process to show.