
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-27-2019 11:54 PM
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
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
-
Team Development
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-28-2019 12:58 AM
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
Abhishek Gardade
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-28-2019 12:27 AM
Hi Raphael,
So in the parent field of sc_req_item you need to populate the CR?
you are creating change request using template
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-28-2019 12:49 AM
Hi Raphael,
Ideally RITM has parent as Request as out of the box functionality
but parent field on sc_req_item table is always empty out of the box; it is only populated when someone created RITM from incident form using UI action
but still if you want then use this approach
create a run script activity in workflow
// query change request table and pick the latest record created and use that; the assumption is there is no other parallel process which created change request or else it will pick wrong change request
var sysId = '';
var gr = new GlideRecord('change_request');
gr.orderByDesc('sys_created_on');
gr.setLimit(1);
gr.query();
if(gr.next()){
sysId = gr.sys_id;
}
current.parent = sysId;
current.update();
Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-17-2021 04:20 AM
how do I make RITM as a parent to change request(standard template).I have used this code to trigger standard change
var templateSysId = " sys_Id";
var changeRecord = new GlideRecord('change_request');
changeRecord.initialize();
GlideTemplate.get(templateSysId).apply(changeRecord);
changeRecord.insert();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-28-2019 12:34 AM
Hi Raphael,
As you are creating the change request from the WF. please dd the run script activity to add the created CR to the parent field on RITM.
Thanks,
Vishal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-28-2019 01:09 AM
Hello Raphael,
Please share a screeshot for the run script activity which is responsible for creating both RITM and CR.
Regards,
Monika