PDAutomationProvider - Scoped, Global

  • Release version: Washingtondc
  • Updated February 1, 2024
  • 5 minutes to read
  • The PDAutomationProvider API enables inserting an optional activity into a process while it's executing.

    This API is part of the Playbooks plugin (com.glide.pad.core) and runs in the sn_pad namespace.

    Calling scripts with this API requires at least one of the following:
    • The caller must be in the same scope in which the optional activity trigger was created.
    • Admin privileges.

    A process is a series of activities ordered by lanes. An optional activity is predefined during process design. The activities aren't scheduled to run at a precise time. An activity can be assigned to a lane and made available to run during lane execution. An activity can be assigned to a process and made available to run during lane execution.

    To create an optional activity, it must have the Start rule set to Manual in the Activities [sys_pd_activity] table. Playbooks doesn't currently support creating manual activities.

    An agent adds the optional activity to a lane or activity relative to another activity. The process must be running to insert an optional activity.

    PDAutomationProvider – addOptionalActivityRelativeToActivityContext(String contextID, String activityId, String where, String relativeToId)

    Adds a specified optional activity to a process to be run relative to another activity during process execution.

    An activity context is created for each activity when a process executes. The context also handles how the activity handles execution. For information, see Process Automation Designer lanes and activities.

    Table 1. Parameters
    Name Type Description
    contextID String Sys_id of the activity execution in which to add the optional activity. To access, click the process listed in the Process Executions [sys_pd_context] table. The execution selected must be in a state of In Progress.
    activityId String Sys_id of the optional activity listed in the Activities [sys_pd_activity] table.
    Note:
    To create an optional activity, it must have the Start rule set to Manual in the Activities [sys_pd_activity] table.
    where String Indicates where to place the activity in the process.
    Valid values:
    • AFTER – Execute this activity after the relative activity context.
    • WITH – Execute the activity at the same time as another relative activity context.
    relativeToId String ID of the relative activity context that the optional activity will run after or with. Listed in the Activity Context [sys_pd_activity_context] table.
    Table 2. Returns
    Type Description
    Boolean Flag that indicates whether the activity was successfully scheduled to run.
    Valid values:
    • true: Activity is successfully scheduled to run. The output is a string stating success.
    • false: Activity isn't successfully scheduled to run. The output is an array of one or more error messages.

    If errors, list of one or more error messages. Message stating Array of 0 or more elements otherwise.

    Array If errors, list of one or more error messages. Message stating Array of 0 or more elements otherwise.
    Possible error messages:
    • Invalid Optional activity Id – The sys_id provided for the activityId parameter is invalid.
    • Invalid PD context Id – The Process Designer (PD) sys_id provided in the contextID parameter is invalid.
    • Invalid position type – The position type provided is invalid. See the description of the where parameter for valid types.
    • Invalid Relative-to Id – The sys_id provided for the relativeToId parameter is invalid.
    • Optional activity not found – The sys_id provided for the activityId parameter wasn't found.
    • Process must still be active – The process containing this activity must be active to run the optional activity.
    • Relative activity context not found – The sys_id provided for the relativeToId parameter was not found.

    The following example shows how to run an optional activity simultaneously with the relative activity context.

    var contextId = '<context_id>';
    var optionalActivityId = '<optional_activity_id>';
    var where = 'WITH'; // options AFTER, WITH
    var relativeToId = '<relative_activity_context_id>'; // relative activity context ID
    
    var response = sn_pad.PDAutomationProvider.addOptionalActivityRelativeToActivityContext(contextId, optionalActivityId, where, relativeToId);
    
    gs.info(JSUtil.describeObject(response));
    Output (success):
    success: boolean = true
    errors: Array of 0 elements

    PDAutomationProvider – addOptionalActivityRelativeToLaneContext(String contextID, String activityId, String where, String relativeToId)

    Assigns an optional activity to a lane to run during that lane's execution context.

    A lane context is created for each lane when a process executes. The context also handles how the lane handles execution. For information, see Process Automation Designer lanes and activities.

    Table 3. Parameters
    Name Type Description
    contextID String Sys_id of the activity execution in which to add the optional activity. To access, click the process listed in the Process Executions [sys_pd_context] table. The execution selected must be in a state of In Progress.
    activityId String Sys_id of the optional activity listed in the Activities [sys_pd_activity] table.
    Note:
    To create an optional activity, it must have the Start rule set to Manual in the Activities [sys_pd_activity] table.
    where String Indicates where to place the activity in the process.
    Valid values:
    • LAST – Execute as the final activity in a lane context.
    • NEXT – Execute in the next activity in a lane context.
    relativeToId String ID of the relative lane context in which the optional activity is to run. Listed in the Lane Context [sys_pd_lane_context] table.
    Table 4. Returns
    Type Description
    Boolean Flag that indicates whether the activity was successfully scheduled to run.
    Valid values:
    • true: Activity is successfully scheduled to run. The output is a string stating success.
    • false: Activity isn't successfully scheduled to run. The output is an array of one or more error messages.
    Array If errors, list of one or more error messages. Message stating Array of 0 or more elements otherwise.
    Possible error messages:
    • Invalid Optional activity Id – The sys_id provided for the activityId parameter is invalid.
    • Invalid PD context Id – The Process Designer (PD) sys_id provided in the contextID parameter is invalid.
    • Invalid position type – The position type provided is invalid. See the description of the where parameter for valid types.
    • Invalid Relative-to Id – The sys_id provided for the relativeToId parameter is invalid.
    • Optional activity cannot be added to lane – The optional activity provided in the activityId parameter can't be added relative to the lane provided in the relativeToId parameter. Make sure that the Activity Execution selected is in the In Progress state.
    • Optional activity not found – The sys_id provided for the activityId parameter wasn't found.
    • Process must still be active – The process containing this activity must be active to run the optional activity.
    • Relative lane context not found – The sys_id provided for the relativeToId parameter was not found.

    The following example shows how to run an optional activity as the final activity in a lane context.

    var contextId = '<context_id>';
    var optionalActivityId = '<optional_activity_id>';
    var where = 'LAST'; // options LAST, NEXT
    var relativeToId = '<relative_lane_context_id>'; // relative lane context ID
    
    var response = sn_pad.PDAutomationProvider.addOptionalActivityRelativeToLaneContext(contextId, optionalActivityId, where, relativeToId);
    
    gs.info(JSUtil.describeObject(response));
    Output (success):
    success: boolean = true
    errors: Array of 0 elements