Starting a workflow within a run script activity

gunishi
Tera Guru

Hi there, 

 

I have a requirement that when a CI is submitted with an excel sheet, new RITMs will be created for each row in the spreadsheet. So far I have managed to create the new RITMs, but I want the same workflow the run script activity is in to run from that point on the new RITMs. How would I go about doing this?

 

Additionally I want to fill in same fields that were on the original service catalog form within the workflow for each of these new RITMs. How would I go about doing this?

 

Any help would be much appreciated. 

 

Kind regards, 

G

4 REPLIES 4

Vishal Birajdar
Giga Sage

Hello @gunishi 

 

Below link might help you..!!

Used same logic as you only I'm creating the multiple RITM using list collector.

 

https://www.servicenow.com/community/developer-forum/create-multiple-ritm-under-single-request-depen...

 

 

Vishal Birajdar
ServiceNow Developer

I know one thing, and that is that I know nothing.
- Socrates

Hi @Vishal Birajdar 

 

Thank you so much for your swift response, I've found all your answers so far very helpful!

Do you think this function would work to trigger a workflow:
function startWorkFlow(ritmSysID) {

var ritm = new GlideRecord('sc_req_item');

ritm.addQuery('request', request);

ritm.addQuery('sys_id', '!=', current.sys_id);

ritm.addNullQuery('context');

ritm.query();

while (ritm.next()) { ritm.setForceUpdate(true);

ritm.update();

}

}

 

Any comments or feedback would be much appreciated. 

 

Kind regards, 

G

Hi @gunishi 

 

This will not start the workflow.

To start workflow you need to pass the workflow context sys_id (wf_workflow table)

Here you are passing the ritm sys_id.

 

 

Vishal Birajdar
ServiceNow Developer

I know one thing, and that is that I know nothing.
- Socrates

Hi @Vishal Birajdar 

 

Thank you so much, this is very helpful. 

 

Kind regards, 

G