DELAYEDWORKFLOW

You can use the DELAYEDWORKFLOW script library to schedule, delay, and repeat workflows on a regular basis. For example, you can schedule Global Calc to run nightly. This library is installed along with the other ION scripts.
Note: You must add the supervisor field for the valid IFS user, AUTOIMPORT. Any delayed workflow ran by the AUTOIMPORT user must add the supervisor field to get the IFS user. Any connection to IDM will be made with that user. The selected user must have IDM access and most of the time, this will be the Optiva service account user. This is only applicable for MT users. See Obtaining IDM user for interacting IDM in workflow in the Infor PLM for Process (Optiva) Application Configuration Guide for more information.

Functions

When you use the functions in this script library, an ActionSetStart.xml file is placed in the COR_INBOX_ENTRY table. The COR_INBOX_ENTRY table is in the central OPTIVAIOBOX database. This file has a time entry that causes the XML Import Listeners to retrieve the workflow at a future time.

Three functions are available. Choose the function that is best suited for your business environment. The second parameter defines the time period that is used by the Script Library.

In the first code block, the second parameter is a TimeSpan object.

Public Sub StartDelayedWorkflow(actionSetCode As String, delay As TimeSpan, symbol As String, key As String, LabCode As String, ParamArray params As String())

In the second code block, the second parameter is an integer that represents a number of days; the third parameter is an integer that represents a number of hours.

Public Sub StartDelayedWorkflow(actionSetCode As String, delayDays As 
Integer, delayHours As Integer, symbol As String, key As String, LabCode As String, ParamArray params As String())

In the third code block, the second parameter is a DateTime object.

Public Sub StartDelayedWorkflow(actionSetCode As String, startDate As DateTime, symbol As String, key As String, LabCode As String, ParamArray params As String())
Input Parameters Description
actionSetCode Specify the action set that you intend to schedule.
TimeSpan Specify the interval in which the workflow is scheduled to run. For example, (0,1,0,0) represents days, hours, minutes and seconds.
symbol Optional. The workflow is scheduled for the current Optiva symbol.
key Optional. The workflow is scheduled for the current object.
LabCode Optional. Specify the lab that runs the Delayed actionSetCode when you schedule a workflow.
ParamArray params Optional. Specify the input parameters in the sequence in which they are displayed in the Action Set > Input tab. You can specify array variables for the input parameters.
delayDays Specify the number of days to delay running the workflow.
delayHours Specify the number of hours to delay running the workflow.
startDate Specify the date and time to begin running the workflow.

Examples for delaying a workflow by hours or days

This workflow is scheduled to run on March 10, 2019. When scheduling a workflow for a specific date, you must schedule it using UTC datetime.

Dim DW As DELAYEDWORKFLOW = new DELAYEDWORKFLOW(Me)
Dim theDate as DateTime = New DateTime(2019, 3, 10)
DW.StartDelayedWorkflow("MYWORKFLOW", theDate, "", "", "", "")

This workflow is delayed by 1 day.

Dim DW As DELAYEDWORKFLOW = new DELAYEDWORKFLOW(Me)
Dim delay as New TimeSpan(1, 0, 0, 0)
DW.StartDelayedWorkflow("MYWORKFLOW", delay, "", "", "", "")

This workflow is delayed by 1 hour.

Dim DW As DELAYEDWORKFLOW = new DELAYEDWORKFLOW(Me)
Dim delay as New TimeSpan(0, 1, 0, 0)
DW.StartDelayedWorkflow("MYWORKFLOW", delay, "", "", "", "")

This workflow is also delayed by 1 hour, using an integer.

Dim DW As DELAYEDWORKFLOW = new DELAYEDWORKFLOW(Me)
DW.StartDelayedWorkflow("MYWORKFLOW", 0, 1, "", "", "", "")

How can you repeat a workflow?

You set the actionSetCode parameter to be the same workflow that you are currently running. So, it launches itself after a delay, every time it runs.

This example shows the workflow FORMULA_UPDATE being delayed for an hour. This script must be contained with the Action that is run by the workflow FORMULA_UPDATE so that it repeats once every hour.

Dim DW As DELAYEDWORKFLOW = new DELAYEDWORKFLOW(Me)
DW.StartDelayedWorkflow("FORMULA_UPDATE", 0, 1, "", "", "", "")

This example shows the workflow MYWORKFLOW being delayed for an hour. This script must be contained with the Action that is run by the workflow MYWORKFLOW so that it repeats once every hour.

Dim DW As DELAYEDWORKFLOW = new DELAYEDWORKFLOW(Me)
Dim delay as New TimeSpan(0,1,0,0)
Dim pArray() as String = {"One","Two"}
DW.StartDelayedWorkflow("MYWORKFLOW",delay,"","","",pArray)

The StartDelayedWorkflow library is not designed to execute a fixed number of times.