Servicely Configuration
Workflow
13 min
servicely provides the ability to create complex custom workflows activity type icon description comment allows the placing of comments onto workflows user action represents a status and a set of actions that are to be made available to users typically used to present a set of options to the user when the workflow is at a point where there are manual actions or decisions that must be made by the user available actions will be presented to the user on the form to allow the user to advance the workflow approval allows approval steps to be added to a workflow complete represents the end/completion of a workflow scriptable provides the ability to run a custom script as part of the workflow designed to be a synchronous script that executes once per pass does not generate a workflow status by default, as the workflow does not pause here scriptable async provides the ability to run a custom script as part of the workflow designed to be used when the action is asynchronous (e g triggering an integration or awaiting other tickets/actions) generates a workflow status so the associated record indicates the wait state timer allows a timer to be scheduled to progress the ticket (e g could be used for auto closure or any other time based progression) if/else provides the ability to branch the workflow based on a simple conditional query switch provides the ability to branch the workflow based on a custom script designed to be a synchronous script that executes once per pass does not generate a workflow status by default, as the workflow does not pause here switch async provides the ability to branch the workflow based on a custom script designed to be used when the action is asynchronous (e g triggering an integration or awaiting other tickets/actions) generates a workflow status so the associated record indicates the wait state run action provides the ability to run an intelligent action exception provides the ability to respond to an exception anywhere in the workflow implementation specifics user action the user action workflow activity provides the ability for end users to control the workflow, by presenting the the user with multiple options to progress the workflow status adding transition options press the ‘add new transition’ button, an enter the new transition name a transition can run a before script for purposes such as making a field to be mandatory before the status transition can take place an example is, to make the assignee field on incident table before moving the incident off from new to work in progress status you would code something like below you will need to end the before script with a return true; statement, so that the rest of the form checks can run to completion linking to next activity drag from the circle in the transition to the left most corner of the target workflow activity approval this activity requests approvals and will stop the records running the workflow from proceeding any further what you can configure item description example approval mechanism section approval requirement whether this approval step only requires one or more approvers to approve before the associated record can proceed to the next step of the approvals options are all approvals required one approval required percentage of approvals required scripted one approval required approval requirement script appears when “approval requirement” is set as “scripted” this is to handle more complex scenarios that the other 3 approval requirement types cannot the script needs to return the answer variable, a value of true indicates an approval while a value of false is for a rejection complete on first rejection appears when the “approval requirement” is set as “one approval required” or “percentage of approvals required” if set to yes, this will move the workflow to the next step on first rejection yes force comment if set to yes, both approval and rejection reasons will ask for comment no approvers section assignees users that will be requested to approve groups groups whose members will be requested to approve advanced approval set to yes if the approver list is not static, e g approver should be ticket’s requestor’s manager yes business logic appears when “advanced approval” is set to yes this needs a script and should return a queried table record object more information on table record, please view table api (server) when approvers are members of a group whose id is defined in an application property let approverarr = table("group") get(applicationpropertymanager getproperty("change approval cab group id")) relation("member") map(approver => approver id());if (approverarr length !== 0) { table("user") in("id", approverarr) map(r => r);} when approver is a manager selected in a catalog item if (current questions() eomanager hasvalue()) { table("user") equal("id", current questions() eomanager value()) map(r => r);} approve if no assignees if set to yes, the approval will be automatically approved if no one is found to be the approvers otherwise the approval will be rejected no templating section subject used in forms and notifications to describe the purpose of the approval cab approval instructions used in forms and notifications to provide instructions to the user about the purpose of the approval approve/reject once cab meeting had been held scriptable activity the ‘scriptable’ activity allows the workflow author to run arbitrary code this activity is typically transient and does not have a workflow status associated with the activity script context the ‘scriptable activity’ receives the following script context items item description current a tablerecord object representing the object associated with the workflow context a plain json map object which can be used to store state associated with the workflow log a script logger that allows logs to be written to the workflowhistory log scriptable async activity the ‘scriptable async’ activity allows the workflow author to run arbitrary code usage is similar to the ‘scriptable activity’ with the primary difference being that this activity is designed to be used when the result of the script is asynchronous (i e the activity needs to wait on something external happening) this activity creates an associated workflow status the scriptable async activity exposes two scripts an initialization script and an evaluation script the initialization script is called once when the activity is initiated, and is designed to be used to perform any initialization associated with the activity (initiate an integration, raise subtasks, etc ) the evaluation script is called asynchronously to determine whether the activity has completed this needs to be performed by an external action (e g on completion of an integration) a convenience method is available to automatically evaluate paused workflows for related tickets (e g for subtasks or other related information) table property description example workflow\ trigger parent field a table property that specifies a relationship that will trigger an asynchronous workflow evaluation of the related record can also be a comma delimited list of relationships on the hrcasetask table, specifying the value “parenthrcase” will enable the evaluation of the workflow related to hrcase records script context the ‘scriptable async activity’ receives the following script context items item description current a tablerecord object representing the object associated with the workflow context a plain json map object which can be used to store state associated with the workflow log a script logger that allows logs to be written to the workflowhistory log activityoptions constants used for the return value or other items within the script scriptable async actions that have not yet completed their requirements should return the value activityoptions delay evaluation scriptable async actions that have completed their requirements should return true execution order when there are multiple workflows for the same table, e g itsm request table having multiple workflows for different catalog items, please ensure that they are ordered accordingly this is necessary for the use case where the workflow is attached to the table not because of service catalog, e g raising itsm request directly when a record such as itsm request is directly created, servicely will select the workflow with lowest order number this means a workflow with order of 10 will take precedence over the one with order of 20