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

 

 

Thank you,
Abhishek Gardade

View solution in original post

14 REPLIES 14

Thank you for this Abhishek!! I believe 'var sysID =change.insert();' should be 'var sysID = grc.insert();' , other than that it works fine! Thanks again!

 

Ohh yes!! you are correct...

Thank you,
Abhishek Gardade

will u please specify how to make ritm as parent for CR....where am triggering the standard change through workflow

var templateSysId = "6e24a61bad7810017ba944b24bcba4";
var changeRecord = new GlideRecord('change_request');
changeRecord.initialize();
GlideTemplate.get(templateSysId).apply(changeRecord);
changeRecord.insert();

Jyoti8
Kilo Guru

Hi Raphael Dizon,

In run script

var change = new GlideRecord('change_request');
change.initialize();
change.applyTemplate('<template name>');
change.cmdb_ci = current.configuration_item;
change.parent = current.sys_id;
change.company = current.company;
change.insert();
if (change) {
	workflow.scratchpad.changeTicket = change.number;
	current.work_notes = 'Change ticket ' + change.number + ' created. Setting Status to Pending.';
	current.state = -5; //set State to "Pending"
}
else {
	activity.result = 'Change not created';
	current.work_notes = 'WARNING - Change not created! Do something manually?';
}

Refer to this link, I hope it will help you.

https://community.servicenow.com/community?id=community_question&sys_id=020dc769db9cdbc01dcaf3231f96...

 

If my reply helps you at all, I’d really appreciate it if you click the Helpful button and if my reply is the answer you were looking for, it would be awesome if you could click both the Helpful and Accepted Solution buttons..:)

Thanks

Hello,

Won't this script make the RITM the parent of the CR? I want to do it the other way around, CR is the parent of RITM.