Update RITM stage from subflow (workflow editor) using inputs and 'run script' activity

sarahleighton
Tera Contributor

Hi, I'm trying to use the workflow scratchpad on a main RITM workflow (using workflow editor not flow designer), and passing the ritm sys_id as an input to a subflow, and then using this in a 'run script' activity in the subflow to set the stage on the RITM.

 

Here's what I've got, but it's not working -

1. Run script in main workflow to save sys_id of current RITM to scratchpad:
Screenshot 2025-01-16 at 08.34.08.png

 

 

2. Add input on subflow:

Screenshot 2025-01-16 at 08.36.05.png

 

3. 'Run script' in subflow, to set a stage on the RITM:

 

var ritm = new GlideRecord (sc_req_item);
ritm.addQuery('sys_id', current.u_ritm);
if (ritm.next) {
ritm.stage == 'HR Approval';
}
 
Any help much appreciated!
Thanks
11 REPLIES 11

Shruti
Mega Sage
Mega Sage
var ritm = new GlideRecord ('sc_req_item');
ritm.addQuery('sys_id', workflow.variables.u_ritm);
ritm.query();
if (ritm.next()) {
ritm.stage = 'HR Approval';
ritm.update();
}

Hi, thanks for your reply.

I just tested this and sadly it's still not updating the stage

Ankur Bawiskar
Tera Patron
Tera Patron

@sarahleighton 

I would like to know how are you calling that subflow from your workflow?

Also why not use run script to update RITM stage rather than using subflow etc?

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi @Ankur Bawiskar 
I am using the 'workflow' activity in the main workflow to call the subflow.

The subflow is running other things not just setting the stage. I would usually use a 'set values' activity to set the stage in an RITM workflow, but in a subflow this doesn't work. Hence, my attempt to use the scratchpad and inputs to run the script in the subflow.