Script Task

A Script Task object represents an activity performed by a Script. Use Scripts in the following ways:

  • Interact with legacy systems in your organization such as ERPs and CRMs.

  • Connect with third-party services like Adobe DocuSign, Amazon Textract, and APIs as well as Robotic Process Automations (RPAs) like UiPath.

Scripts are designed in Script Editor. Scripts are independent of Process models: any Script can be reused in any Process model in your organization. This architecture allows Process Owners to focus on Process modeling in a no-code environment while ProcessMaker Developers develop reusable Scripts. Scripts can leverage Screens variable values for in-progress Requests.


Add a Script Task to the Process Model

Permissions

Your user account or group membership must have the following permissions to configure a Script Task object in the Process model unless your user account has the Make this user a Super Admin setting selected:

  • Processes: Edit Processes

  • Processes: View Processes

See the Process permissions or ask your Administrator for assistance.

Add a Script Task object from one of the following locations in Process Modeler:

  • Object Panel: Located to the left of the Process Modeler, the Object Panel contains various process modeling objects.

  • Object Bar: Located at the bottom of the Process Modeler, the Object Bar contains pinned Process modeling objects for quick access.

Follow these steps to add a Script Task from the Object panel to the Process model:

  1. Ensure that the Object panel is visible. If not, click the Add icon from the Object bar at the bottom.

  2. Click the Task object from the Object panel to select it.

  3. Click the location in the Process model to place this object. Follow these guidelines when placing this object:

    • If your process has a Pool object, the object cannot be placed outside of the Pool.

    • To place this object between two existing objects, follow these instructions.

  4. Click the objects drop-down menu, and then select the Script Task option.

    The Script Task object displays.

Follow these steps to add a Script Task object from the Objects bar to the Process model:

  1. Ensure that the object is pinned to the Object bar. If not, see instructions to pin it.

  2. In the Object bar at the bottom center, click the object's icon.

  3. Click the location in the Process model to place this object. Follow these guidelines when placing this object:

    • If your process has a Pool object, the object cannot be placed outside of the Pool.

    • To place this object between two existing objects, follow these instructions.

  4. Click the Objects drop-down menu, and then select the Script Task option.

    The Script Task object displays.  

Add boundary events
After adding an object to a process, consider adding the following events to handle exceptions:

Replace a Script Task Object with a Different Task Type or Sub Process Object

After a Script Task object is added to a Process model, you may replace it with a different Task type or a Sub Process object:

The selected Script Task object is replaced by the default settings and color of the replacing object.

Follow these steps to replace a Script Task object with a different Task type object or a Sub Process object:

  1. Select the Script Task object to change to another object. Available options display above the selected object.

  2. Click the Objects icon. The Objects drop-down menu displays the Task type objects and the Sub Process object.

  3. Select the object to replace the Script Task object. The Change Type screen displays to confirm replacing the currently selected object.

  4. Click Confirm. The new object replaces the Script Task object with its default settings and color.

Preview the Script for the Task

After a Script Task object is added to a Process model and selected the Script to run for the Task, you may preview the associated Script, which allows you to interact with and verify the Script content in the same Process Modeler.

Follow these steps to preview the associated Script from a Script Task object:

  1. Select the Script Task object to preview the associated Script. Available options display above the selected object.

  2. Click the Preview icon . A preview window displays on the right-side of the Process Modeler.

    Previewing the Script for a Script Task object

  3. In the Preview window, you can do the following:

    • Click the icon to open the Script Editor to edit the Script.

    • Click the icon to close the preview window.

    • Click another Task or connector object to change the asset in the same preview window.

  4. The following message displays if you try to preview a task with no associated scripts.


Settings

The Script Task object has the following panels that contain settings:


Properties Panel Settings

The Script Task object has the following settings in the Properties panel:

Edit the Object Name

An object name is a human-readable reference for a process object. Process Modeler automatically assigns the name of a Process object with its object type. However, an object's name can be changed.

Follow these steps to edit the name for a Script Task object:

  1. Select the Script Task object from the Process model in which to edit its name.

  2. Ensure that the Configuration panel displays. If not, show it. The Name setting displays. This is a required setting.

  3. In the Name setting, edit the selected object's name and then press Enter.

Select the Script to Run

Since Script Task objects are designed to run a Script, specify which Script a selected Script Task object uses. A Script must already exist before it can be selected for use in a Script Task object.

See the following topics for more information:

Ensure to select a Script for each Script Task object in your Process model. If a Script is not specified and Requests are started for that Process, a placeholder Script displays when that Script Task object triggers.

The placeholder Script allows the Request without causing it to pause indefinitely.

This functionality also allows Process Designers to place the basic Process objects into a Process model and then evaluate it during development.

Follow these steps to select a Script for a Script Task object:

  1. Select the Script Task object from the Process model in which to specify its Script.

  2. Ensure that the Configuration panel displays. If not, show it. Panels to configure this object display.

  3. Expand the Configuration panel if it is not presently expanded, and then locate the Script setting.  

  4. Do one of the following:

    • From the Script drop-down menu, select which Script that Script Task object references. After a Script is selected, the Open Script link displays.

    • Click the Create a new script link. A new browser window opens to create a new Script.  After creating the Script, the Script drop-down menu automatically populates with the created Script. Otherwise, be sure to select the new Script in the Script drop-down menu.

  5. Optionally, click the Open Script link to view and/or edit your Script. Note that your user account must have appropriate Script category permissions or be a Project member in which this Script is an asset.

If no Scripts exist, the Script drop-down menu contains no options. Ensure to select and configure a Script for every Script Task object in the Process model before deploying your Process.

Configure the Selected Script

After selecting the Script for the Script Task object, optionally provide a JSON object that configures variable values for the selected Script. Providing a JSON script from the Script Task is identical to providing JSON configuration script in the Script Config JSON panel in Scripts Editor for a Script.

See the following topics for more information:

If a JSON script exists in the Script Task object, that script is used for the Script. An existing JSON configuration script displays in the Script Configuration option for a selected Script Task object.

The JSON script in the Script Task object overrides any JSON script entered in the Script Config JSON panel in Scripts Editor for the associated Script.

Follow these steps to enter or edit a JSON configuration script for a Script Task object:

  1. Select the Script Task object from the Process model in which to specify its Script.

  2. Ensure that the Configuration panel displays. If not, show it. Panels to configure this object display.

  3. Expand the Configuration panel if it is not presently expanded, and then locate the Script Configuration option.  

  4. Select the Script this Script Task object runs.

  5. Click the iconbeside the Script Configuration option. The Script Config Editor displays.  

  6. Enter your JSON configuration script. Use the scroll panel to the right of the Script to scroll to different sections of the Script if necessary. This is useful especially when you are editing a long Script.

  7. Click Close or the Close icon.

You can enter your JSON configuration script directly into the Script Configuration option instead of using the Script Config Editor.

Add a Placeholder for the Slideshow Mode

The Slideshow Mode makes it easy for process designers to share the design of a process with all stakeholders, regardless of whether they have access to the ProcessMaker Platform. For more information on how to create slideshows for a process, see Slideshow Mode.

Follow these steps to add a placeholder image for the Slideshow Mode:

  1. Select the Form Task object from the Process model.

  2. Click the icon to view the Configuration panel.

  3. From the Placeholder for Slideshow section, click on the +Drag or click here button to upload an image.

  4. A preview of the image will display, and the configuration will be auto-saved.

  5. The uploaded image will be shown for this task the next time the slideshow is viewed.

Notes:

  • Size of a placeholder image for slideshows must less than 2 MB.

  • Image files with PNG, JPG, JPEG, and GIF extensions are supported.


Loop Characteristics Panel Setting

Use the Loop Activity panel settings to specify how to perform multiple instances of this object. The following loop modes are available:

No Loop Mode

Select the No Loop Mode option to perform this object's Task only once.

Follow these steps to specify characteristics to perform multiple instances of the Task:‌

  1. Select the Task from the Process model. Panels to configure this object display.

  2. Expand the Loop Activity panel. By default, the Loop Mode setting is set to No Loop Mode and the function is performed only once.

Loop

Select the Loop option to sequentially repeat this Task's function multiple times until an exit condition is True. This is useful when a function should be performed multiple times with the same set of data, such as, processing a credit card payment. This loop mode has the following characteristics:

  • The Task's function is repeated until the exit condition is True or the maximum iterations limit is reached.

  • At any given time, only one instance of the Task is active. The subsequent instance does not begin until the current instance completes.

  • The same exit condition evaluates at the end of each instance; however, value(s) of the Request variable(s) used in the exit condition can change during an instance resulting in the exit condition to eventually evaluate as True.

  • If any one instance of that function does not complete, workflow pauses.

  • All active instances are terminated if an interrupting boundary-type event object triggers. An object configured in this mode shows the Loop icon in Process Modeler.

Follow these steps to specify characteristics to perform multiple instances of the Task:‌

  1. Select the Task from the Process model in which to specify multiple instance characteristics. Panels to configure this object display.

  2. Expand the Loop Activity panel to display the Loop Mode Setting.

  3. From the Loop Mode setting, select the Loop option. The settings for this loop mode display:

  4. In the Maximum Iterations setting, enter an integer value representing the maximum number of times this Task should be performed.

  5. In the Exit Condition setting, enter a condition in FEEL syntax. When this condition is True the loop activity is halted.

Multi-instance (Sequential)

Select the Multi-instance (Parallel) option to perform this Task's Task multiple times in parallel a fixed number of times. This is useful when performing any action in bulk, such as sending an email to several people. This loop mode has the following characteristics:

  • Instances of the Task are governed by the size of an array-type Request variable where a new instance is created for each item in this variable. For example, an array with 10 items will create 10 parallel instances of this function that each contains data from its respective array index.

  • All instances begin simultaneously when this Task triggers; however, they perform their function independently of each other.

  • The function as a whole completes when all instances are complete.

  • The output from each instance can either be saved in the source Request variable or a new array-type Request variable.

  • All active instances terminate if an interrupting boundary-type event object triggers.

  • A Task configured in this mode shows the Multi-instance (Parallel) icon in Process Modeler.

Follow these steps to specify characteristics to perform multiple instances of the Task:‌

  1. Select the Task from the Process model in which to specify multiple instance characteristics. Panels to configure this object display.

  2. Expand the Loop Activity panel to display the Loop Mode Setting.

  3. From the Loop Mode setting, select the Multi-instance (Parallel) option. The settings for this loop mode display:

  4. In the Request Variable Array setting, enter the name of an array-type Request variable. The size of this array will determine how many times this loop iterates.

  5. In the Output Data Variable setting, enter the name of an array-type Request variable in which to store the results of all instances. Each instance of the loop saves to a separate JSON object within the array of the specified Request variable. If the Output Data Variable setting is not configured, then the output data replaces the source data in the Request Variable Array.

Multi-instance(Sequential)

Select the Multi-instance (Sequential) option to perform this Task's function multiple times sequentially a fixed number of times or until an exit condition is True. This is useful when sequentially repeating a function multiple times but with a different set of data each time. This loop mode has the following characteristics:

  • Instances of the function are governed by the size an array-type Request variable where a new instance is created for each item in this variable. For example, an array with 10 items will create 10 parallel instances of this function that each contains data from its respect array index.

  • At any given time, only one instance of the function is active. The subsequent instance does not begin until the current instance completes.

  • At the end of each instance an exit condition evaluates and the loop activity halts if the exit condition is True.

  • The function as a whole completes when all instances are complete.

  • The output from each instance can either be saved in the source Request variable or a new array-type Request variable.

  • All active instances terminate if an interrupting boundary-type event object triggers.

  • A Task configured in this mode shows the Multi-instance (Sequential) iconin Process Modeler.

Follow these steps to specify characteristics to perform multiple instances of the Task:‌

  1. Select the Task from the Process model in which to specify multiple instance characteristics. Panels to configure this object display.

  2. Expand the Loop Activity panel to display the Loop Mode Setting.

  3. From the Loop Mode setting, select the Multi-instance (Sequential) option. The settings for this loop mode display:

  4. In the Request Variable Array setting, enter the name of an array-type Request variable. The size of this array will determine how many times this loop iterates.

  5. In the Exit Condition setting, enter a condition in FEEL syntax. When this condition is True the loop activity is halted.

  6. In the Output Data Variable setting, enter the name of an array-type Request variable in which to store the results of all instances. Each instance of the loop saves to a separate JSON object within the array of the specified Request variable. If the Output Data Variable setting is not configured, then the output data replaces the source data in the Request Variable Array.


Documentation Panel Settings

Describe the object's purpose and how it functions in the Process. This description does not affect Requests for the Process, but may be useful for Process model maintenance such as how the object is configured. Edit information by using the What-You-See-Is-What-You-Get (WYSIWYG) rich text editor.

A Process's entered documentation displays by selecting the View Documentation icon for that Process.

Edit the Object's Description Displayed in Process Documentation

Follow these steps to edit the description for an object:

  1. Select the object from the Process model in which to edit its description.

  2. Ensure that the Configuration panel displays. If not, show it. Panels to configure this object display.

  3. Expand the Documentation panel if it is not presently expanded. The Description setting displays.

  4. In the Description setting, edit the information to display when viewing documentation for this object and then press Enter. Alternatively, use the What-You-See-Is-What-You-Get (WYSIWYG) rich text editor to stylize your text by clicking the More icon.

    Follow these guidelines to use the WYSIWYG rich text editor to stylize your text:

    • Undo changes: Click on theicon to undo the last action.

    • Redo changes: Click on theicon to redo the last undone action.

    • Insert/Edit Link: Click on theicon to convert the selected text into a hyperlink. Follow these steps to create a hyperlink:

      1. Select the required text from the Rich Text control.

      2. Click on theicon. The Insert/Edit Link screen displays.  

      3. In the URL setting, enter the destination URL.

      4. In the Text to display setting, edit or enter the text displayed in the Rich Text control.

      5. In the Title setting, enter the text to display when a user hovers over the displayed text.

      6. From Open link in… drop-down menu, select one of these options:

        • New window: Select this option to open the destination page in a new browser window.

        • Current window: Select this option to open the destination page in the current browser window.

    • Insert/Edit Image: Click on the Insert/Edit Image iconto insert an image. Follow these guidelines:

      1. Click on the Insert/Edit Image icon.

      2. The Insert/Edit Image screen displays:  

      3. In the Source setting, enter a URL for the image.

      4. In the Alternative Description setting, enter the text to display if the source URL of the image is not accessible.

      5. In the Width setting, enter the maximum width for the image.

      6. In the Height setting, enter the maximum height for the image.

      7. Toggle the Constrain Proportions iconto maintain the width-height ratio of the image to its original proportion.

      8. Click Save.

    • Insert Page Break for PDF: Click on the Insert Page Break for PDF iconto insert a page break when a PDF document is created for this documentation if your browser supports this feature.

    • Format text: Follow these guidelines to format text:

      • Headings: From the Paragraph/Formats menu, select Headings and then select a heading size.

      • Bold: Do one of the following:

        • From the editor toolbar, select theicon.

        • From the Paragraph/Formats menu, select Inline and then Bold.

      • Italics: Do one of the following:

        • From the editor toolbar, select theicon.

        • From the Paragraph/Formats menu, select Inline and then Italic.

      • Underline: From the Paragraph/Formats menu, select Inline and then Underline.

      • Strikethrough: From the Paragraph/Formats menu, select Inline and then Strikethrough.

      • Superscript: From the Paragraph/ Formats menu, select Inline and then Superscript.

      • Subscript: From the Paragraph/Formats menu, select Inline and then Subscript.

      • Code: From the Paragraph/Formats menu, select Inline and then Code.

      • Paragraph: From the Paragraph/Formats menu, select Blocks and then Paragraph.

      • Blockquote: From the Paragraph/Formats menu, select Blocks and then Blockquote.

      • Division: From the Paragraph/Formats menu, select Blocks and then Div.

      • Preformatted:  From the Paragraph/Formats menu, select Blocks and then Pre.

      • Change text color: Use the Text Color drop-down to change text color. Click on theicon. The color palette displays. Do one of the following:

        • Select one of the color swatches from the color palette. The selected text changes to that color.

          • Click theicon to select a custom color from the Color Picker.

          • Click theicon to reset the text to its default color.

      • Align text: Follow these guidelines to align text:

        • Left align: Do one of the following:

          • From the editor toolbar, use theicon to left-align text.

          • From the Paragraph/Formats menu, select Align and then Left.

        • Center align: Do one of the following:

          • From the editor toolbar, use theicon to center-align text.

          • From the Paragraph/Formats menu, select Align and then Center.

        • Right align: Do one of the following:

          • From the editor toolbar, use theicon to right-align text.

          • From the Paragraph/Formats menu, select Align and then Right.

        • Justify: Do one of the following:

          • From the editor toolbar, use theicon to justify text.

          • From the Paragraph/Formats menu, select Align and then Justify.

      • Insert a bullet list: Use theicon to format text as a bulleted list.

      • Insert a numbered list:  Use theicon to format text as a numbered list.

      • Indent text: Click on theicon to increase text indenting.

      • Outdent text: Click on theicon to decrease text indenting.


Error Handling Panel Settings

Edit Timeout and Retry Settings When Errors Occur

Follow these guidelines to set how to handle Script Task runtime errors:

  • Set how many seconds to wait when an unexpected error occurs during runtime before displaying the error in that Script Task, thereby causing that Request to be in Error status.

  • Set how many consecutive attempts to run the Script Task before displaying a runtime error.

Requests are going to wait the configured number of seconds and consecutive runtime attempts for an unresponsive Script Task before displaying the error.

Optionally, notify the Process Manager of the Script Task runtime error via an in-platform or email notification.

Follow these steps to edit the Error Handling settings:

  1. Select the Script Task object from the Process model in which to edit the Error Handling.

  2. Ensure that the Configuration panel displays. If not, show it. Panels to configure this object display.

  3. Expand the Error Handling panel if it is not presently expanded. The Timeout setting displays.

  4. In the Timeout setting, configure how many seconds to wait for an unresponsive Script Task before declaring a time-out as follows:

    • Enter the number of seconds. Use the up and down arrows to increase or decrease seconds.

    • Set 0 for no timeout.

    • Leave empty to use the Script Task default setting.

  5. In the Retry Attempts setting, configure how many times to re-run the Script Task if the Script Task returns a runtime error as follows:

    • Enter a number. Use the up and down arrows to increase or decrease the number.

    • Set 0 for no retry attempts.

    • Leave empty to use the Script Task default setting.

  6. In the Retry Wait Time setting, configure how many seconds to wait before attempting a retry as follows:

    • Enter the number of seconds. Use the up and down arrows to increase or decrease seconds.

    • Set 0 for no timeout.

    • Leave empty to use the Script Task default setting.

  7. Enable the In-app Notification toggle to notify through the user interface to the Process Manager that there is a Script Task runtime error.

  8. Enable the Email Notification toggle to notify through an email to the Process Manager that there is a Script Task runtime error.


Vocabularies Panel Settings

Vocabularies validate that Request data complies with a specific JSON schema. This is often mandatory for many types of business sectors including banking and healthcare ensuring the quality and compliance of Request data. For example, during a Loan Application process, ensure that all required personal information has been included in the Request.

Use a Vocabulary on a Form Task to validate that Request data complies with the Vocabulary's JSON schema after the Task assignee submits the Task. Multiple Vocabularies can be assigned to a Form Task object. During an in-progress Request, if the Request data no longer complies with all assigned Vocabularies, the Request status changes from In Progress to Error in the Request summary. Vocabularies are cumulative in an in-progress Request: as the Request progresses, if Request data does not conform with any Vocabulary's JSON schema, the request status displays an error. For more information What is a Vocabulary? and Create a New Vocabulary.

Assign Vocabularies That Validate Request Data

Follow these steps to assign Vocabularies that validate Request data from a Script Task object:

  1. Select the Script Task object from the Process model in which to assign Vocabularies that validate Request data prior to when this object completes.

  2. Ensure that the Configuration panel displays. If not, show it. Panels to configure this object display.

  3. Expand the Vocabularies panel if it is not presently expanded. The Assigned setting displays.

  4. Click theicon to add a Vocabulary. The Assign Vocabulary setting displays.

  5. From the Select Vocabulary drop-down menu, select a Vocabulary from which to validate Request data complies with its JSON schema.

    If no Vocabularies are configured, then the following message displays: List is empty. Create at least one Vocabulary. See Create a New Vocabulary.

  6. Click Save.

  7. Repeat Steps 3 through 6 as necessary for each Vocabulary required to validate Request data complies with its JSON schema.

Click the Remove iconfrom the Vocabularies setting to remove a Vocabulary from assignment to this object.

After one or more Vocabularies are assigned to a Script Task object, the Vocabulary icon displays in that object.

Advanced Panel Settings

Edit the Node's Identifier Value

Process Modeler automatically assigns a unique value to each Process node added to a Process model. However, a node's identifier value can be changed if it is unique to all other nodes in the Process model, including the Process model's identifier value.

All identifier values for all nodes in the Process model must be unique.

Follow these steps to edit the identifier value for a Script Task object:

  1. Select the Script Task object from the Process model in which to edit its identifier value.

  2. Ensure that the Configuration panel displays. If not, show it. Panels to configure this object display.

  3. Expand the Advanced panel if it is not presently expanded. The Node Identifier setting displays. This is a required setting.  

  4. In the Node Identifier setting, edit the Script Task object's identifier to a unique value from all nodes in the Process model and then press Enter.