How to set the parent of RITM to the CR created via workflow

Raphael Dizon
Mega Expert

Hello,

I have a workflow in which when you submit the form, it will create a RITM and a Change Request at the same time. Is it possible to set the CR created as the parent of the RITM created? If yes, how can I do it in the workflow. Thank you.

Kind Regards,

Raphael

1 ACCEPTED SOLUTION

I would suggest,

1. Add a RUN SCRIPT activity , in place of CREATE TASK.

2. Add below code for creating change request and setting parent of RITM:

var grc= new GlideRecord('change_request');

grc.initialize();

grc.cmdb_ci = current.cmdb_ci ; // current.cmdb_ci : this will copy CMDB from RITM to CHANGE

grc.field_Name_on_CR= current.field_Name_on_RITM; // replace with your values that you want to set 

var sysID =change.insert(); // store sys_id of change request created

current.parent  =  sysID  // This will set parent for RITM

current.update();

3. In this way you can avoid setting,issue mentioned on my above comment.

Please mark as Correct Answer/Helpful, if applicable.
Thanks!
Abhishek Gardade

 

 

View solution in original post

14 REPLIES 14

AbhishekGardade
Tera Sage

Hello Raphael,

What are you creating first in workflow? RITM Or Change? Are you using a same activity for creating both records? 

Yes you can set CR as parent for the RITM.

Can you share a script for creating a RITM & CR? or a screenshot?

Please mark as Correct Answer/Helpful, if applicable.
Thanks!
Abhishek Gardade

In my workflow I have a 'Create Task' activity that creates the CR once the catalog form is submitted. I did not use script for creating the CR.

 

find_real_file.png

Hello Raphel,

I have created this activity and created a change request.

1.When you Submitted a SR form. A service Request has been created and with the workflow Change has been created as well

2. As I can see in change request table RITM IS A PARENT FOR THE CHANGE and it should be as its created from workflow of RITM.

3. So logically with OOTB functionality the scenario is :

For change request : PARENT IS RITM

and after we configured your scenario:

For change request : PARENT IS RITM

FOR RITM : PARENT IS CHANGE REQUEST

same records are pointing each other as parent.

3. But still if you wan to configure then create a AFTER INSERT business rule on change table and add below code:

var gr = new GlideRecord('sc_req_item');
gr.addQuery('sys_id','parent'); // Field on CR or
gr.query();

if(gr.next()){

gr.parent = current.sys_id // it will set parent for RITM 

gr.update();

}

Please mark as Correct Answer/Helpful, if applicable.
Thanks!
Abhishek Gardade

I would suggest,

1. Add a RUN SCRIPT activity , in place of CREATE TASK.

2. Add below code for creating change request and setting parent of RITM:

var grc= new GlideRecord('change_request');

grc.initialize();

grc.cmdb_ci = current.cmdb_ci ; // current.cmdb_ci : this will copy CMDB from RITM to CHANGE

grc.field_Name_on_CR= current.field_Name_on_RITM; // replace with your values that you want to set 

var sysID =change.insert(); // store sys_id of change request created

current.parent  =  sysID  // This will set parent for RITM

current.update();

3. In this way you can avoid setting,issue mentioned on my above comment.

Please mark as Correct Answer/Helpful, if applicable.
Thanks!
Abhishek Gardade