Custom Code Parameters
The following tables describe the input and return parameters available to each custom code script type in Easy Workflow. Use this reference alongside the Info Help panel in the custom code editor.
Post step custom action parameters
The post step custom script runs after a user performs an action on a workflow step. The script receives contextual input parameters and returns values that control workflow routing, assignment, and behavior for the next step.
Input parameters
| Parameter | Type | Description |
|---|---|---|
iSheet |
Worksheet object | Current active worksheet object. |
intCurStepNo |
Integer | Current step number. |
IterationCount |
Integer | Current step iteration number. |
FileID |
Integer | Current workitem file ID. |
AssignType |
String |
Assign type of the step. Valid values:
|
AssignUserName |
String | Username to whom the current step is assigned when AssignType is U. |
AssignGroupName |
String | Group name to whom the current step is assigned when AssignType is G. |
iStepType |
Integer |
Step type. Valid values:
|
iUserName |
String | Environment or cloud username of the user who performed the action. |
iUserDisplayName |
String | Display name of the user who performed the action. |
iUserEmailAddress |
String | Email address of the user who performed the action. |
iSourceOfStepAction |
String |
Source from which the action was performed. Valid values:
|
iStepAction |
Enum |
Action performed on the step. Valid values:
|
iRunResult |
Integer |
Run completion status. Valid values:
|
CustomTables |
DataTableCollection | Custom tables selected for the current workflow. |
EmailInfo |
Class object | Email object information. Available only when the action is performed through email. See EmailInfo properties. |
iRunStatusColumn |
String | Status column of the current execution. Applicable for Auto Run (SAP), Auto Test Run (SAP), Auto Error Processing (SAP), and Auto Validate Data Governance Rule (ICP) step types only. |
iWorkflowInitiatorName |
String | Username who initiated the workflow. |
iSourceOfStart |
Integer |
Source from which the workflow was started. Valid values:
|
EmailInfo properties
The EmailInfo object provides the following properties when a step action is performed through email.
| Property | Description |
|---|---|
MessageID |
Message ID from the email header. |
VerificationCode |
Code used for two-stage validation of the email. |
EmailTo |
Send To email address. |
EmailCc |
Send Cc email address. |
MultipleEmailTo |
Multiple To email addresses. |
EmailFrom |
Send From email address. |
EmailSubject |
Email subject line. |
EmailBody |
Email body in HTML format. |
EmailPlainBody |
Email body in plain text format. |
EmailDate |
Date the email was sent. |
InternetHeader |
Header information of the email. |
Attachments |
DataTable containing details of the attachments sent with the email. |
Return parameters
The following parameters are set by the post step custom script to control workflow behavior after the step action.
| Parameter | Type | Description |
|---|---|---|
iRetStepNo |
Integer | Step number to go to next. If both iRetStepNo and iRetUniqueStepID are set, iRetUniqueStepID takes priority and iRetStepNo is ignored. |
iRetUniqueStepID |
String | Unique step ID to go to next. Takes priority over iRetStepNo if both are set. |
iRetUserName |
String | Username or user ID to assign the next step task. |
iRetGroupName |
String | Group name or group ID to assign the next step task. |
CustomFieldsValue[1–15] |
String | Values of custom fields defined in the workflow for the workitem. Can be used to read and write custom field values for the current workitem. |
iRetEmailList |
String | Comma-separated list of email addresses to send email to based on the custom code. |
iRetAllowReassign |
Integer |
Enables or disables the auto reassign setting for the next step task. Valid values:
|
iRetReassignUserName |
String | Username or user ID to assign as the auto reassign user for the next step task. |
iRetReassignGroupName |
String | Group name or group ID to assign as the auto reassign group for the next step task. |
iRetReassignPeriod |
String |
Auto reassign period for the next step task. Use the format
|
iRetPriority |
Class object |
Priority of the workitem. Valid values:
|
iRetWorkflowAction |
Class object |
Next action for the workflow to perform. Valid values:
|
Note: In parallel step configurations, iRetStepNo cannot target a step within its own running parallel block. If it does, the return value is ignored and the next consecutive step runs instead.
Example
The following example routes the workflow to different steps based on an Excel cell value and the action performed by the user.
If Convert.ToInt32(iSheet.Cells(10, "C").Value) > 100 And iStepAction = StepAction.Approve Then
iRetStepNo = 3
iRetUserName = "TestUser1"
Else
iRetStepNo = 4
End If
Pre step custom action parameters
The pre step custom script runs before a workflow step is presented to the user. Use this script to perform validation, lock or unlock worksheet ranges, and control whether the workflow can proceed.
Input parameters
The pre step custom script receives the following input parameters.
| Parameter | Type | Description |
|---|---|---|
iSheet |
Worksheet object | Current active worksheet object. |
intCurStepNo |
Integer | Current step number. |
IterationCount |
Integer | Current step iteration number. |
FileID |
Integer | Current workitem file ID. |
AssignType |
String |
Assign type of the step. Valid values:
|
AssignUserName |
String | Username to whom the step is assigned when AssignType is U. |
AssignGroupName |
String | Group name to whom the step is assigned when AssignType is G. |
iStepType |
Integer |
Step type. Valid values:
|
iUserName |
String | Environment or cloud username of the user who performed the task. |
iUserDisplayName |
String | Display name of the user who performed the action. |
iUserEmailAddress |
String | Email address of the user who performed the action. |
iSourceOfStepAction |
String |
Source from which the action was performed. Valid values:
|
CustomTables |
DataTableCollection | Custom tables selected for the current workflow. |
iWorkflowInitiatorName |
String | Username who initiated the workflow. |
iSourceOfStart |
Integer |
Source from which the workflow was started. Valid values:
|
Return parameters
The following parameters are set by the pre step custom script to control behavior before the step is presented to the user.
| Parameter | Type | Description |
|---|---|---|
iRetStepNo |
Integer | Step number to go to next. See important note below before using this parameter in pre step code. |
iRetUniqueStepID |
String | Unique step ID to go to next. Takes priority over iRetStepNo if both are set. See important note below before using this parameter in pre step code. |
iRetUserName |
String | Username or user ID to assign the current step task. See important note below before using this parameter in pre step code. |
iRetGroupName |
String | Group name or group ID to assign the current step task. See important note below before using this parameter in pre step code. |
CustomFieldsValue[1–15] |
String | Values of custom fields defined in the workflow for the workitem. Can be used to read and write custom field values for the current workitem. |
iRetEmailList |
String | Comma-separated list of email addresses to send email to based on the custom code. |
iRetStartWFValidate |
Boolean |
Validates whether the user can start the workflow on the selected template. Available for the pre step custom code of the first workflow step only. Valid values:
|
iReturnID |
String | Validation message ID displayed to the user when workflow start is blocked. Used only when iRetStartWFValidate is set to False. Available for the pre step custom code of the first workflow step only. |
iReturnMessage |
String | Validation message displayed to the user when workflow start is blocked. Used only when iRetStartWFValidate is set to False. Available for the pre step custom code of the first workflow step only. |
iRetAllowReassign |
Integer |
Enables or disables the auto reassign setting for the current or next step task. Valid values:
|
iRetReassignUserName |
String | Username or user ID to assign as the auto reassign user for the current or next step task. |
iRetReassignGroupName |
String | Group name or group ID to assign as the auto reassign group for the current or next step task. |
iRetReassignPeriod |
String |
Auto reassign period for the current or next step task. Use the format
|
iRetPriority |
Class object |
Priority of the workitem. Valid values:
|
iRetWorkflowAction |
Class object |
Next action for the workflow to perform. Valid values:
|
iRunStatusColumn |
String | Status column where the run status is stored. Applicable for Auto Error Processing (SAP) step type only. |
Note: Do not use iRetStepNo, iRetUserName, or iRetGroupName in pre step custom code to change the step routing or user assignment. To change the step or assigned user, use the post step custom code of the preceding step instead.
Note: In parallel step configurations, iRetStepNo cannot target a step within its own running parallel block. If it does, the return value is ignored and the next consecutive step runs instead.
Example: Lock and unlock worksheet ranges
The following example unlocks and locks specific column ranges on the worksheet when the step loads.
iSheet.Unprotect()
iSheet.Columns("BA:BE").Locked = True
iSheet.Columns("BF:BM").Locked = False
iSheet.Protect(DrawingObjects:=True, Contents:=True, Scenarios:=True)
Auto custom action parameters
The auto custom action script runs automatically as a workflow step, without requiring user interaction. In addition to controlling workflow routing, this script type can start new workflows and export reports.
Input parameters
The auto custom action script receives the following input parameters.
| Parameter | Type | Description |
|---|---|---|
iSheet |
Worksheet object | Current active worksheet object. |
intCurStepNo |
Integer | Current workflow step number. |
IterationCount |
Integer | Current step iteration number. |
FileID |
Integer | Current workitem file ID. |
AssignType |
String |
Assign type of the step. Valid values:
|
AssignUserName |
String | Username to whom the step is assigned when AssignType is U. |
AssignGroupName |
String | Group name to whom the step is assigned when AssignType is G. |
iStepType |
Integer |
Step type. Valid values:
|
iUserName |
String | Environment or cloud username of the user who performed the task. |
CustomTables |
DataTableCollection | Custom tables selected for the current workflow. |
iWorkflowInitiatorName |
String | Username who initiated the workflow. |
iSourceOfStart |
Integer |
Source from which the workflow was started. Valid values:
|
Return parameters
The following parameters are set by the auto custom action script to control workflow behavior and step outcomes.
| Parameter | Type | Description |
|---|---|---|
iRetStepNo |
Integer | Step number to go to next. If both iRetStepNo and iRetUniqueStepID are set, iRetUniqueStepID takes priority and iRetStepNo is ignored. |
iRetUniqueStepID |
String | Unique step ID to go to next. Takes priority over iRetStepNo if both are set. |
iRetUserName |
String | Username to assign the next step task. |
iRetGroupName |
String | Group name to assign the next step task. |
CustomFieldsValue[1–15] |
String | Values of custom fields defined in the workflow for the workitem. Can be used to read and write custom field values for the current workitem. |
iRetEmailList |
String | Comma-separated list of email addresses to send email to based on the custom code. |
iRetStepAction |
Integer |
Step action to perform based on the custom code result. Used only in Auto Custom Action steps. If not set, the step is approved by default and the workflow moves to the next step. Valid values:
|
iRetStepComment |
String | Step comment to apply based on the custom code result. Used only in Auto Custom Action steps. If not set, the default step comment is used. |
iRetAllowReassign |
Integer |
Enables or disables the auto reassign setting for the next step task. Valid values:
|
iRetReassignUserName |
String | Username or user ID to assign as the auto reassign user for the next step task. |
iRetReassignGroupName |
String | Group name or group ID to assign as the auto reassign group for the next step task. |
iRetReassignPeriod |
String |
Auto reassign period for the next step task. Use the format
|
iRetPriority |
Class object |
Priority of the workitem. Valid values:
|
iRetWorkflowAction |
Class object |
Next action for the workflow to perform. Valid values:
|
Note: In parallel step configurations, iRetStepNo cannot target a step within its own running parallel block. If it does, the return value is ignored and the next consecutive step runs instead.
Example: Route the workflow based on a cell value
The following example routes the workflow to a different step based on an Excel cell value.
If Convert.ToInt32(iSheet.Cells(10, "C").Value) > 100 Then
iRetStepNo = 3
iRetUserName = "TestUser1"
Else
iRetStepNo = 4
End If
Example: Start a workflow on an EShare template
The following example starts a new workflow on an EShare template from within auto custom code.
'--- User inputs ---
Dim TemplateId As Integer = 1 'EShare template ID
Dim WorkflowId As Integer = 1 'Workflow ID
Dim UserNameToStart As String = IEWFSupport.CloudLic.CurrentUserName
Dim NewExcelFileName As String = "Temp Test" + System.DateTime.Now.ToString("yyyymmdd_HHMMss")
'--- Execution ---
Dim RetNewFileID As Integer = 0
Dim RetWorkItemID As Integer = 0
Dim WFState As IEWFSupport.UpdateWFState
WFState = New IEWFSupport.UpdateWFState
WFState.StartWorkflow(IEWFSupport.Common.ProductType.AutoCustomCode, TemplateId, WorkflowId, UserNameToStart, True, NewExcelFileName, RetNewFileID, RetWorkItemID)
Note: The first parameter must always be IEWFSupport.Common.ProductType.AutoCustomCode.
Example: Start a workflow on a local Excel file
The following example starts a new workflow on a local Excel file from within auto custom code.
'--- User inputs ---
Dim LocalFilePath As String = "C:\Temp\Temp Test.xlsx" 'Full path including file name
Dim WorkflowId As Integer = 1 'Workflow ID
Dim UserNameToStart As String = IEWFSupport.CloudLic.CurrentUserName
Dim NewExcelFileName As String = "Temp Test" + System.DateTime.Now.ToString("yyyymmdd_HHMMss")
Dim UploadFileEvenOnError As Boolean = True 'Upload to EShare even if workflow start fails
'--- Execution ---
Dim RetNewFileID As Integer = 0
Dim RetWorkItemID As Integer = 0
Dim WFState As IEWFSupport.UpdateWFState
WFState = New IEWFSupport.UpdateWFState
WFState.StartWorkflow(LocalFilePath, NewExcelFileName, WorkflowId, UserNameToStart, RetNewFileID, RetWorkItemID, CallerTypeS:=IEWFSupport.Common.ProductType.AutoCustomCode, UploadFileEvenOnError:=UploadFileEvenOnError)
Example: Export a workflow report
The following example exports an Easy Workflow report to a specified file path from within auto custom code.
'--- User inputs ---
Dim _RptName As IEWFReports.Common.EnumSaver.ReportName = IEWFReports.Common.EnumSaver.ReportName.WorkItemDetailReport
Dim _RPTExt As IEWFReports.Common.EnumSaver.ReportExtention = IEWFReports.Common.EnumSaver.ReportExtention.PDF
Dim _FileID As Integer = FileID 'Workitem ID for which the report is generated
Dim _ExportedReportName As String = "C:\Temp\SampleReport"
'--- Execution ---
Dim RptObj As IEWFReports.ReportCaller
RptObj = New IEWFReports.ReportCaller
RptObj.ExportIEWFReports(_RptName, _RPTExt, _FileID, _ExportedReportName)
Example: Download supporting documents attached to a workitem
The following example downloads the supporting documents attached to a workitem to a specified local path.
'--- User inputs ---
Dim _FileID As Integer = FileID 'Workitem ID
Dim _DocumentDownloadPath As String = "C:\Temp\DocumentDownload"
'--- Execution ---
Dim SupportDocObj As IEWFSupport.AttachSupportDoc
SupportDocObj = New IEWFSupport.AttachSupportDoc
SupportDocObj.DownloadAttachSupportingDocument(_FileID, _DocumentDownloadPath)