Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Trigger RITM Approvals in Request flow

Kalyan520
Tera Contributor

Hello Folks,

I have a requirement to trigger approvals on RITM level in a workflow which is on Request, Can some one please help me to achieve this. I have described my requirement below.

find_real_file.png

I can achieve it by creating workflow on rimt and can associate to specific cat item. So the ritm flow runs only after the request is approved. here I need this approval in between request approvals.

 

Thanks

Ram

1 REPLY 1

SumanthDosapati
Mega Sage
Mega Sage

Hi kalyan,

In your workflow, after your first two approvals, generate an approval to RITM table with a run script activity.

You can try below code in run script activity

var ritm = new GlideRecord('sc_req_item');
ritm.addQuery('request',current.sys_id);
ritm.query();
if(ritm.next()) //assuming there is only one RITM under REQ. If more than one then use while instead of if
{
var ritm_sys_id = ritm.sys_id;
}

var approval = new GlideRecord('sysapproval_approver');
approval.initialize();
approval.setValue('sysapproval',ritm_sys_id);
approval.setValue('approver','sys_id_of_approver user');// give approver sysid here
approval.setValue('state','requested');
approval.insert();

 

After this run script activity you can put a wait for activity and proceed with the flow.

 

Mark as correct and helpful if it works.

Regards,

Sumanth