IafWorkflowSvc
Use the IafWorkflowSvc API to manage workflows and their components, schedules, tasks, and permissions on the platform.
createJobTrigger
Creates a trigger for a workflow job
| Parameter | Required | Type | Description |
|---|---|---|---|
| workflowDefId | Yes | String | Workflow definition ID |
| jobKey | Yes | String | Job Key |
| payload | Yes | Object | Trigger payload |
| ctx | Yes | Object | Context object |
Promise<Object> - Created trigger
const trigger = await IafWorkflowSvc.createJobTrigger('workflowDefId', 'jobKey', payload, ctx);
createPermissions
Creates workflow permissions
| Parameter | Required | Type | Description |
|---|---|---|---|
| permissions | Yes | Array<IafPermissionDescriptor> | Permissions array |
| ctx | Yes | Object | Context object |
Promise<Object> - Permissions response
await IafWorkflowSvc.createPermissions([{ _resourceDesc: {} }], ctx);
createWorkflowDef
Creates a new Workflow definition
| Parameter | Required | Type | Description |
|---|---|---|---|
| workflowDef | Yes | WorkflowDef | Workflow definition payload |
| ctx | Yes | Object | Context object |
Promise<WorkflowDef> - Created Workflow definition
const newDef = await IafWorkflowSvc.createWorkflowDef(workflowDef, ctx);
createWorkflowSchedule
Creates a workflow schedule
| Parameter | Required | Type | Description |
|---|---|---|---|
| workflowDefId | Yes | String | Workflow definition ID |
| workflowSchedule | Yes | Object | Workflow schedule payload |
| ctx | Yes | Object | Context object |
Promise<Object> - Created workflow schedule
const schedule = await IafWorkflowSvc.createWorkflowSchedule(workflowDefId, payload, ctx);
deletePermission
Deletes a workflow permission by ID
| Parameter | Required | Type | Description |
|---|---|---|---|
| id | Yes | String | Permission ID |
| ctx | Yes | Object | Context object |
Promise<Object> - Delete response
await IafWorkflowSvc.deletePermission('permId', ctx);
deleteWorkflowDef
Deletes a workflow definition
| Parameter | Required | Type | Description |
|---|---|---|---|
| workflowDefId | Yes | String | Workflow definition ID |
| ctx | Yes | Object | Context object |
Promise<Object> - Delete response.
await IafWorkflowSvc.deleteWorkflowDef(workflowDefId, ctx);
deleteWorkflowJob
Deletes a workflow schedule job by jobKey
| Parameter | Required | Type | Description |
|---|---|---|---|
| workflowDefId | Yes | String | Workflow definition ID |
| jobKey | Yes | String | Job Key |
| ctx | Yes | Object | Context object |
Promise<Object> - Delete response
await IafWorkflowSvc.deleteWorkflowJob('workflowDefId', 'jobKey', ctx);
deleteWorkflowScheduleJob
Deletes a workflow schedule job
| Parameter | Required | Type | Description |
|---|---|---|---|
| workflowDefId | Yes | String | Workflow definition ID |
| jobId | Yes | String | Job ID |
| ctx | Yes | Object | Context object |
Promise<Object> - Delete response
await IafWorkflowSvc.deleteWorkflowScheduleJob('workflowDefId', 'jobId', ctx);
deleteWorkflowSchedules
Deletes all workflow schedules for a workflow definition
| Parameter | Required | Type | Description |
|---|---|---|---|
| workflowDefId | Yes | String | Workflow definition ID |
| ctx | Yes | Object | Context object |
Promise<Object> - Delete response
await IafWorkflowSvc.deleteWorkflowSchedules('workflowDefId', ctx);
deleteWorkflowScheduleTrigger
Deletes a trigger for a workflow schedule
| Parameter | Required | Type | Description |
|---|---|---|---|
| workflowDefId | Yes | String | Workflow definition ID |
| triggerId | Yes | String | Trigger ID |
| ctx | Yes | Object | Context object |
Promise<Object> - Delete response
await IafWorkflowSvc.deleteWorkflowScheduleTrigger('workflowDefId', 'triggerId', ctx);
deleteWorkflowTrigger
Deletes a workflow trigger by triggerKey
| Parameter | Required | Type | Description |
|---|---|---|---|
| workflowDefId | Yes | String | Workflow definition ID |
| triggerKey | Yes | String | Trigger Key |
| ctx | Yes | Object | Context object |
Promise<Object> - Delete response
await IafWorkflowSvc.deleteWorkflowTrigger('workflowDefId', 'triggerKey', ctx);
getAllSchedules
Fetches all schedules (across all workflow definitions or for a specific workflow definition)
| Parameter | Required | Type | Description |
|---|---|---|---|
| workflowDefId | No | (String | UNKNOWN: NullLiteral) | Workflow definition ID to filter schedules (optional) |
| ctx | Yes | Object | Context object |
| options | No | Object | Output control options (e.g., _pageSize, _offset, sort) |
Promise<Object> - All schedules
const schedules = await IafWorkflowSvc.getAllSchedules('workflowDefId', ctx, { _pageSize: 10 });
const allSchedules = await IafWorkflowSvc.getAllSchedules(null, ctx, { _pageSize: 20 });
getLoopOverTasks
Fetches loop-over tasks for a workflow.
| Parameter | Required | Type | Description |
|---|---|---|---|
| workflowId | Yes | String | Workflow ID. |
| taskId | Yes | String | Task ID. |
| ctx | Yes | Object | Context object. |
| criteria | No | Object | Filter criteria for loop-over tasks. |
| options | No | Object | Output control options (e.g., _pageSize, _offset, sort) |
Promise<Array<TaskDef>> - Loop-over tasks.
const loops = await IafWorkflowSvc.getLoopOverTasks(
workflowId,
taskId,
ctx,
{ _name: 'TaskName' },
{ _pageSize: 10, _offset: 0, sort: { _createdAt: -1 } }
);
getPermissions
Gets workflow permissions based on your criteria
| Parameter | Required | Type | Description |
|---|---|---|---|
| criteria | Yes | PermissionCriteria | Filter criteria. |
| ctx | Yes | Object | Context object. |
Promise<Object> - Permissions.
const perms = await IafWorkflowSvc.getPermissions({ type: 'read' }, ctx);
getTaskById
Fetches a task by Workflow and Task IDs
| Parameter | Required | Type | Description |
|---|---|---|---|
| workflowId | Yes | String | Workflow ID |
| taskId | Yes | String | Task ID |
| ctx | Yes | Object | Context object |
Promise<TaskDef> - The fetched Task
const task = await IafWorkflowSvc.getTaskById(workflowId, taskId, ctx);
getTaskDefById
Gets a task definition by ID (GET /workflowdefs/{workflowDefId}/taskdefs/{taskDefId})
| Parameter | Required | Type | Description |
|---|---|---|---|
| workflowDefId | Yes | String | Workflow definition ID |
| taskDefId | Yes | String | Task definition ID |
| ctx | Yes | Object | Context object |
Promise<Object> - Task definition
const taskDef = await IafWorkflowSvc.getTaskDefById(workflowDefId, taskDefId, ctx);
getTaskDefs
Gets all task definitions for a workflow definition (GET /workflowdefs/{workflowDefId}/taskdefs)
| Parameter | Required | Type | Description |
|---|---|---|---|
| workflowDefId | Yes | String | Workflow definition ID |
| ctx | Yes | Object | Context object |
| criteria | No | Object | Filter criteria for task definitions |
| options | No | Object | Output control options (e.g., _pageSize, _offset, sort) |
Promise<Object> - Task definitions
const taskDefs = await IafWorkflowSvc.getTaskDefs(
workflowDefId,
ctx,
{ _name: 'TaskName' },
{ _pageSize: 10, _offset: 0, sort: { _createdAt: -1 } }
);
getTaskLogsById
Fetches Task logs for a workflow.
| Parameter | Required | Type | Description |
|---|---|---|---|
| workflowId | Yes | String | Workflow ID. |
| taskId | Yes | String | Task ID. |
| ctx | Yes | Object | Context object. |
| criteria | No | Object | Filter criteria for logs. |
| options | No | Object | Output control options (e.g., _pageSize, _offset, sort) |
const logs = await IafWorkflowSvc.getTaskLogsById(
workflowId,
taskId,
ctx,
{ _type: 'ERROR' },
{ _pageSize: 20, _offset: 0, sort: { _createdAt: -1 } }
);
getWorkflowComponents
Gets workflow components (GET /workflowdefs/components) with optional filtering and pagination
| Parameter | Required | Type | Description |
|---|---|---|---|
| ctx | Yes | Object | Context object |
| name | No | String | Optional name filter for components |
| options | No | Object | Output control options (e.g., _pageSize, _offset) |
Promise<Object> - Workflow components
const components = await IafWorkflowSvc.getWorkflowComponents(ctx, 'ComponentName', { _pageSize: 10, _offset: 0 });
const allComponents = await IafWorkflowSvc.getWorkflowComponents(ctx, null, { _pageSize: 20 });
getWorkflowDef
Fetches a workflow definition by ID
| Parameter | Required | Type | Description |
|---|---|---|---|
| workflowDefId | Yes | String | Workflow definition ID |
| ctx | Yes | Object | Context object |
Promise<WorkflowDef> - Workflow definition
const def = await IafWorkflowSvc.getWorkflowDef(workflowDefId, ctx);
getWorkflowDefs
Fetches workflow definitions based the criteria you pass
| Parameter | Required | Type | Description |
|---|---|---|---|
| criteria | No | WorkflowDefCriteria | Filter criteria for workflows. |
| ctx | Yes | Object | Context object |
| options | No | WorkflowDefOptions | Pagination control options. |
Promise<Array<WorkflowDef>> - Workflow definitions.
const defs = await IafWorkflowSvc.getWorkflowDefs(
{ _name: 'Equipment-Commissioning' },
ctx,
{ _count: 10, _offset: 0 }
);
getWorkflowJob
Fetches a workflow schedule job by jobKey
| Parameter | Required | Type | Description |
|---|---|---|---|
| workflowDefId | Yes | String | Workflow definition ID |
| jobKey | Yes | String | Job Key |
| ctx | Yes | Object | Context object |
Promise<Object> - Workflow schedule job
const job = await IafWorkflowSvc.getWorkflowJob('workflowDefId', 'jobKey', ctx);
getWorkflowJobTriggers
Fetches all triggers for a workflow schedule job, with optional pagination
| Parameter | Required | Type | Description |
|---|---|---|---|
| workflowDefId | Yes | String | Workflow definition ID |
| jobKey | Yes | String | Job Key |
| ctx | Yes | Object | Context object |
| options | No | Object | Output control options (e.g., _pageSize, _offset) |
Promise<Object> - Triggers for the job
const triggers = await IafWorkflowSvc.getWorkflowJobTriggers('workflowDefId', 'jobKey', ctx, { _pageSize: 10, _offset: 0 });
getWorkflowParamsMap
Gets workflow parameter map (POST /workflowdefs/paramsMap)
| Parameter | Required | Type | Description |
|---|---|---|---|
| params | Yes | Object | Parameters object with clientId and clientSecret |
| ctx | Yes | Object | Context object |
Promise<Object> - Workflow params map
const paramsMap = await IafWorkflowSvc.getWorkflowParamsMap({ clientId, clientSecret }, ctx);
getWorkflows
Fetches workflows based on the criteria and options you pass
| Parameter | Required | Type | Description |
|---|---|---|---|
| criteria | No | Object | Filter criteria for workflows (e.g., _name, _defId, _status, startDate, endDate) |
| ctx | Yes | Object | Context object |
| options | No | Object | Output control options (e.g., _pageSize, _offset, sort) |
Promise<Array<Workflow>> - Workflows.
// Basic usage with name and status
const workflows = await IafWorkflowSvc.getWorkflows(
{ _name: 'MyWorkflow', _status: 'ACTIVE' },
ctx,
{ _pageSize: 10, _offset: 0, sort: { _createdAt: -1 } }
);
// Usage with _defId in criteria to filter by workflow definition
const filteredWorkflows = await IafWorkflowSvc.getWorkflows(
{ _defId: 'someDefId' },
ctx,
{ _pageSize: 5 }
);
getWorkflowScheduleJob
Fetches a workflow schedule job by ID
| Parameter | Required | Type | Description |
|---|---|---|---|
| workflowDefId | Yes | String | Workflow definition ID |
| jobId | Yes | String | Job ID |
| ctx | Yes | Object | Context object |
Promise<Object> - Workflow schedule job
const job = await IafWorkflowSvc.getWorkflowScheduleJob('workflowDefId', 'jobId', ctx);
getWorkflowScheduleJobTriggers
Fetches all triggers for a workflow schedule job, with optional pagination
| Parameter | Required | Type | Description |
|---|---|---|---|
| workflowDefId | Yes | String | Workflow definition ID |
| jobId | Yes | String | Job ID |
| ctx | Yes | Object | Context object |
| options | No | Object | Output control options (e.g., _pageSize, _offset) |
Promise<Object> - Triggers for the job
const triggers = await IafWorkflowSvc.getWorkflowScheduleJobTriggers('workflowDefId', 'jobId', ctx, { _pageSize: 10, _offset: 0 });
getWorkflowSchedules
Fetches all workflow schedules for a workflow definition, with optional pagination
| Parameter | Required | Type | Description |
|---|---|---|---|
| workflowDefId | Yes | String | Workflow definition ID |
| ctx | Yes | Object | Context object |
| options | No | Object | Output control options (e.g., _pageSize, _offset) |
Promise<Object> - Workflow schedules
const schedules = await IafWorkflowSvc.getWorkflowSchedules('workflowDefId', ctx, { _pageSize: 10, _offset: 0 });
getWorkflowStatus
Gets workflow status by run ID
| Parameter | Required | Type | Description |
|---|---|---|---|
| runId | Yes | String | Workflow run ID |
| ctx | Yes | Object | Context object |
Promise<Object> - Workflow status
const status = await IafWorkflowSvc.getWorkflowStatus(runId, ctx);
getWorkflowTriggers
Fetches all triggers for a workflow definition, with optional pagination
| Parameter | Required | Type | Description |
|---|---|---|---|
| workflowDefId | Yes | String | Workflow definition ID |
| ctx | Yes | Object | Context object |
| options | No | Object | Output control options (e.g., _pageSize, _offset) |
Promise<Object> - Triggers for the workflow definition
const triggers = await IafWorkflowSvc.getWorkflowTriggers('workflowDefId', ctx, { _pageSize: 10, _offset: 0 });
runWorkflow
Runs a Workflow
| Parameter | Required | Type | Description |
|---|---|---|---|
| workflowDefId | Yes | String | Workflow definition ID |
| params | Yes | Object | Input parameters for the workflow |
| ctx | Yes | Object | Context object |
Promise<Object> - Run response
const params = { _workflowDefId: workflowDefId };
const result = await IafWorkflowSvc.runWorkflow(workflowDefId, params, ctx);
updatePermissions
Updates a Workflow's permissions
| Parameter | Required | Type | Description |
|---|---|---|---|
| permissions | Yes | Array<IafPermissionDescriptor> | Permissions array |
| ctx | Yes | Object | Context object |
Promise<Object> - Update response
await IafWorkflowSvc.updatePermissions([{ _resourceDesc: {} }], ctx);
updateUserInput
Updates the user input for a workflow
| Parameter | Required | Type | Description |
|---|---|---|---|
| workflowId | Yes | String | Workflow ID |
| userInputId | Yes | String | User input ID |
| payload | Yes | Object | User input payload |
| ctx | Yes | Object | Context object |
Promise<Object> - Updated response
await IafWorkflowSvc.updateUserInput(workflowId, userInputId, payload, ctx);
updateWorkflowDef
Updates an existing Workflow definition
| Parameter | Required | Type | Description |
|---|---|---|---|
| workflowDefId | Yes | String | Workflow definition ID |
| workflowDef | Yes | WorkflowDef | Updated workflow definition payload |
| ctx | Yes | Object | Context object. |
Promise<WorkflowDef> - Updated workflow definition
const updated = await IafWorkflowSvc.updateWorkflowDef(workflowDefId, workflowDef, ctx);
updateWorkflowStatus
Updates a workflow by run ID
| Parameter | Required | Type | Description |
|---|---|---|---|
| workflowRunId | Yes | String | Workflow run ID |
| params | Yes | WorkflowDef | Input parameters for the workflow |
| ctx | Yes | Object | Context object |
Promise<Workflow> - Update response.
await IafWorkflowSvc.updateWorkflow('runId', ctx);