Workflow ​
Workflow helper library.
Static properties ​
instanceId string ​
The current workflow instance id.
instance WorkflowInstance ​
The current workflow instance information.
signal any ​
Signal data.
signalObject { [key: string]: any; } ​
Signal data as an object. If the signal data is not an object, this will be null.
tags { [key: string]: any; } ​
Metric tags to override the default tags for the generated alerts.
Methods ​
createSignalUrl ​
createSignalUrl(nextStep: string, token: any, title?: string, redirectUrl?: string)Create a signal url.
Parameters
nextStep string
The ID or name of the next step.
token any
The token or signal data. This corresponds to a branch name of the given next step
title string
(optional) The title of the signal.
redirectUrl string
(optional) The redirect URL to send the user to after clicking the signal URL. URL parameters 'instanceId', 'stepId' and 'signal' will be added to the URL.
Return type
string
Examples
// Create a signal URL using the given next step: Workflow.createSignalUrl
Workflow.createSignalUrl('nextStepId', 'token')
// Create a signal URL and redirect to a workspace page
// (This assumes you have a workspace page in your Rulecube org with the URL 'your-landing-page')
Workflow.createSignalUrl('nextStepId', 'token', 'Token title', '/#/w/your-org/page/your-landing-page')createNextSignalUrl ​
createNextSignalUrl(token: any, title?: string, redirectUrl?: string)Create a signal url using the configured next step.
Parameters
token any
The token or signal data. This corresponds to a branch name of the next step.
title string
(optional) The title of the signal.
redirectUrl string
(optional) The redirect URL to send the user to after clicking the signal URL. URL parameters 'instanceId', 'stepId' and 'signal' will be added to the URL.
Return type
string
Examples
// Create a signal URL using the configured next step: Workflow.createNextSignalUrl
Workflow.createNextSignalUrl('token')
// Create a signal URL and redirect to a workspace page
// (This assumes you have a workspace page in your Rulecube org with the URL 'your-landing-page')
Workflow.createNextSignalUrl('token', 'Token title', '/#/w/your-org/page/your-landing-page')sendHubSignal ​
sendHubSignal(name: string, data: { [key: string]: any; })Send a signal to all Hub clients connected to the workflow instance.
Parameters
name string
The name of the signal.
data { [key: string]: any; }
The data to send.
Return type
void
Examples
createWebhookUrl ​
createWebhookUrl(stepId: string)Create a webhook url for a specific workflow step.
Parameters
stepId string
The ID of the workflow step.
Return type
string
createNextWebhookUrl ​
createNextWebhookUrl()Create a webhook url for the next workflow step.
Parameters
Return type
string
Examples
// Assuming the next step is an Upload step of type 'Webhook'
let webhookUrl = Workflow.createNextWebhookUrl('stepId')
// Use imaginary payment provider to create a payment and set the webhook URL:
// This payment provider will call the webhook URL when the payment is completed
Http.post('https://payment-provider.com/create-payment', { amount: 100, currency: 'EUR', webhookUrl: webhookUrl })queue ​
queue(name: string, version: string, input: { [key: string]: any; }, options?: { [key: string]: any; }, tags?: string[])Queue another workflow ruleset to start.
Parameters
name string
The name of the workflow ruleset.
version string
The version of the workflow ruleset.
input { [key: string]: any; }
The input data for the workflow.
options { [key: string]: any; }
(optional) The options for the workflow.
tags string[]
(optional) The tags for the workflow.
Return type
void
queueLibrary ​
queueLibrary(library: Function, input: { [key: string]: any; }, options?: { [key: string]: any; }, tags?: string[])Queue another workflow library ruleset to start.
Parameters
library Function
The library that is a workflow ruleset.
input { [key: string]: any; }
The input data for the workflow.
options { [key: string]: any; }
(optional) The options for the workflow.
tags string[]
(optional) The tags for the workflow.
Return type
void
getDocuments ​
getDocuments()Get all documents from the workflow. Requires for the calling workflow step to have 'Access Documents' enabled.
Parameters
Return type
WorkflowDocument[]
getDocument ​
getDocument(documentTypeName: string)Get a document from the workflow. Requires for the calling workflow step to have 'Access Documents' enabled.
Parameters
documentTypeName string
The name of the document type. Should match one defined under the 'Document Types' section of the workflow Settings.
Return type
WorkflowDocument
getDocumentDataUri ​
getDocumentDataUri(documentTypeName: string)Get the contents of a document as a data URI. Requires for the calling workflow step to have 'Access Documents' enabled.
Parameters
documentTypeName string
The name of the document type. Should match one defined under the 'Document Types' section of the workflow Settings.
Return type
string
saveDocument ​
saveDocument(documentTypeName: string, dataUri: string, fileName?: string)Save a document to the workflow.
Parameters
documentTypeName string
The name of the document type. Should match one defined under the 'Document Types' section of the workflow Settings.
dataUri string
The Base64 data URI of the document.
fileName string
(optional) The name of the file.
Return type
void
Examples
// This assumes there is a Document Type defined in the workflow with the name 'MyDocument'.'
Workflow.saveDocument('MyDocument', 'data:text/plain;base64,SG93ZHkgcGFydG5lciE=');
// The 3rd parameter is optional and can be used to set the file name.
Workflow.saveDocument('MyDocument', 'data:text/plain;base64,SG93ZHkgcGFydG5lciE=', 'MyFile.txt');getDocumentTypes ​
getDocumentTypes()Get the document types defined in the workflow settings.
Parameters
Return type
WorkflowDocumentType[]
Examples
Workflow.getDocumentTypes() // Get the document types defined in the workflow settingsremoveDocuments ​
removeDocuments(documentTypeName: string)Remove all documents of a specific type from the workflow instance.
Parameters
documentTypeName string
The name of the document type. Should match one defined under the 'Document Types' section of the workflow Settings.
Return type
void
Examples
// This assumes there is a Document Type defined in the workflow with the name 'MyDocument'.'
Workflow.removeDocuments('MyDocument');removeDocument ​
removeDocument(id: string)Remove a specific document from the workflow instance.
Parameters
id string
The ID of the document to remove.
Return type
void
Examples
// Remove a document by its ID
Workflow.removeDocument('documentId');setProgress ​
setProgress(completed: number, total: number)Set the progress of the workflow.
Parameters
completed number
The number of completed items.
total number
The total number of items.
Return type
void
setStage ​
setStage(stage: string)Set the custom stage of the workflow.
Parameters
stage string
The custom stage of the workflow.
Return type
void
Examples
Workflow.setStage('My custom stage');setName ​
setName(name: string)Set the name of the workflow instance.
Parameters
name string
The name of the workflow instance.
Return type
void
stop ​
stop(message?: string)Stop the workflow gracefully. State changes will be saved.
Parameters
message string
(optional) The message to log.
Return type
void
getPreviousAlerts ​
getPreviousAlerts()Get the previous alerts for the current step. These are the alerts that were by the direct previous step(s).
Parameters
Return type
Alert[]
clearAlerts ​
clearAlerts()Clear all alerts from the workflow instance.
Parameters
Return type
void
getPreviousTasks ​
getPreviousTasks()Get the previous tasks for the current step. These are the tasks that link to the current step's input node.
Parameters
Return type
WorkflowTask[]
getPreviousTask ​
getPreviousTask()Get the most recent previous task for the current step.
Parameters
Return type
WorkflowTask
getPreviousTaskComment ​
getPreviousTaskComment()Get the comment of the most recent previous task for the current step.
Parameters
Return type
string
assignUser ​
assignUser(userId: string)Assign a user to the workflow instance, so they can access it.
Parameters
userId string
The ID of the user to assign.
Return type
void
Examples
Workflow.assignUser('userId');unassignUser ​
unassignUser(userId: string)Unassign a user from the workflow instance, so they can no longer access it.
Parameters
userId string
The ID of the user to unassign.
Return type
void
Examples
Workflow.unassignUser('userId');