0% found this document useful (0 votes)
77 views5 pages

Flow Designer - Writeup

The document describes creating a custom activity for Process Automation Designer. The activity will create a task record from flow data. It defines an action to create the task, a subflow to encapsulate the logic, and the steps within the subflow to create flow data, lookup the record, and create the task record.

Uploaded by

Amitabh Biswas
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
77 views5 pages

Flow Designer - Writeup

The document describes creating a custom activity for Process Automation Designer. The activity will create a task record from flow data. It defines an action to create the task, a subflow to encapsulate the logic, and the steps within the subflow to create flow data, lookup the record, and create the task record.

Uploaded by

Amitabh Biswas
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Goal: Custom activity for Process Automation Designer

What needs to be done:

1. Action
2. Subflow
3. Activity Definition

Step 1 - Action: Create an action “Create CSM Task From Flow Data”
1. Create Input
Label Name Type Mandatory
a. Flow Data flow_data Reference.Flow Data Yes
2. Create Script “Create Task from Flow Data”
i. Required Runtime: Instance
ii. Input Variables:

Name Value
a. flow_data_sys_id Inputs>Flow Data>Sys ID

iii. Script:

(function execute(inputs, outputs) {

var flow_data = new GlideRecord('sys_flow_data');

flow_data.get(inputs.flow_data_sys_id);

var table, fields = "";

if((flow_data.vars.table + "")!='')

table = flow_data.vars.table;

if((flow_data.vars.assigned_to + "")!='')

fields += "assigned_to=" + flow_data.vars.assigned_to;

if((flow_data.vars.short_description + "")!='')

fields += "^short_description=" + flow_data.vars.short_description;

if((flow_data.vars.additional_fields + "")!='')

fields += "^" + flow_data.vars.additional_fields;

if(table && fields){

var gr = new GlideRecord(table);

gr.initialize();

gr.applyEncodedQuery(fields);

if(gr.insert()){

outputs.table = table;

outputs.record = gr;
iv. Output Variables

Label Name Type Mandatory


a. Table table Table Name Yes
b. Record record Document ID.Task(sn_customerservice_task) Yes
c. Status status String Yes
v. If this step fails: Stop the action and go to error evaluation

3. Action Output
Label Name Type Mandatory
a. Table table Table Name No
b. Record record Document ID.Task(sn_customerservice_task) No
c. Status status Choice No

c.Status Choice List Default Value = Success

Name Value Order


-- None -- 0
Missing table or fields missing_data 1
Error error 2
Success success 3

Label Value
a. Table Step > Create Task from Flow Data > Table
b. Record Step > Create Task from Flow Data > record
c. Status Step > Create Task from Flow Data > Status

Step 2 - Subflow: Create a Subflow “Create CSM Task Activity”


*Modify system property “sn_flow_designer.allowed_system_tables” to include table “sys_flow_data”
otherwise you cannot select the table in flow designer.

1. Subflow Inputs & Outputs


i. Inputs

Label Name Type Mandatory Default Value


a. Assignment Group assignment_group Reference.Group No
for this Process Step
b. Assigned to this assigned_to Reference.User No
Process Step
c. Task Table Table Table No sn_customerservi
ce_case
d. Assigned To assigned_to_new_r Reference.User No
ecord
e. Short Description short_description String No
f. Fields fields Template Value No Yes
g. Wait for user input wait Choice No
h. Fields to show after fields_to_show_aft Field List No
creation er_creation
i. Wait for task wait_for_task_com True/False No
completion pletion

f. Dependent on Task Table


g. Name Value Order
 No no 0
 Yes yes 1
h. Dependent on Task Table

ii. Outputs

Label Name Type


a. Automated Automated True/False
b. Table Table Table
c. Record record Reference.Task
sn_customerservice_task
d. Form Fields form_fields String
e. Record Fields record_fields String

2. Actions
i. Action: Create Flow Data
o Action: Create Flow Data
o Definition [Data Definition]: Create Task
o Assigned To [User]: Inputs > Assigned to this Process Step
o Wait for user input: No
o Assignment group [Group]: Inputs > Assignment Group for this Process Step
o State: Pending

ii. Action: Log


o Action: Log
o Level: Info
o Message: Scripted (Expand to edit)
var flow_data = new GlideRecord('sys_flow_data');

flow_data.get(fd_data._1__create_flow_data.record.sys_i
d + "");
flow_data.vars.table = fd_data.subflow_inputs.table;
flow_data.vars.assigned_to =
fd_data.subflow_inputs.assigned_to_new_record;
flow_data.vars.short_description =
fd_data.subflow_inputs.short_description;
flow_data.vars.additional_fields =
fd_data.subflow_inputs.fields;
flow_data.update();
return flow_data.vars.table + " - " +
flow_data.vars.short_description + " - " +
flow_data.vars.assigned_to + " - " +
flow_data.vars.additional_fields;

iii. Flow Logic: Assign Subflow Outputs


o Automated: Scripted

return fd_data.subflow_inputs.wait!='yes';

o Table: Flow Data(sys_flow_data)


o Form Fields: vars
o Record Fields: vars.table,vars.short_description,vars.assigned_to

iv. Flow Logic: If


o Condition:
Input > Wait for user input: No

v. Action: Update Record


o Record: i. Create Flow Data > Record
o Table: Flow Data[sys_flow_data]
o Fields:
State: Complete

vi. Action: Wait For Condition


o Record: i. Create Flow Data > Record
o Table: Flow Data[sys_flow_data]
o Conditions:
State: Complete/Skipped/Error/Cancelled

vii. Action: Look Up Record


o Table: Flow Data[sys_flow_data]
o Condition:
Sys ID: i. Create Flow Data > Record > Sys ID
o If multiple records are found action: Return only the first record
o Don't fail on error: True

viii. Flow Logic: If


o Condition:
vii. Look Up Flow Data Record > Flow Data Record > State: Complete

ix. Action: Create CSM Task from Flow Data


o Flow Data [Flow Data]: vii. Look Up Flow Data Record > Flow Data Record

x. Flow Logic: Assign Subflow Outputs


o Table: return fd_data._7__look_up_record.record.vars.table + ""; (scripted)
o Record: ix. Create CSM Task from Flow Data > Record
o Form Fields:
o Record Fields: Input > Fields to show after creation

xi. Flow Logic: If


o Condition:
Input > Wait for task completion: True

xii. Action: Wait for Condition


o Record: ix. Create CSM Task from Flow Data > Record
o Table: Task[sn_customerservice_task]
o Conditions:
State: Closed

You might also like