How to update parent record using business rule
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-05-2020 03:46 AM
Hi All,
I have created a after business rule. When change is created need to update the change record in the under parent field in release table.
below is the script.
var gr=new GlideRecord('rm_release');
gr.addQuery('change_request',current.sys_id);
gr.query();
if(gr.next()){
gr.parent=current.sys_id;
gr.update();
}
Thank You,
Sai.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-05-2020 03:52 AM
Hi Sai,
What is going wrong with the script? It seems fine to me.
As per your script below:
var gr=new GlideRecord('rm_release');
gr.addQuery('change_request',current.sys_id);
gr.query();
if(gr.next()){
gr.parent=current.sys_id;
gr.update();
}
It is fine only, but in screenshot you are setting a number value there you need to set the sys_id only.
Regards,
Mohit Kaushik
Mohit Kaushik
ServiceNow MVP (2023-2025)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-05-2020 03:56 AM
You're finding the release on the basis of the change_request field being populated with a reference to the current record so why do you need to create another reference to the current record with the parent field?
If you definitely need it, the parent field is a reference field so you'll need to give it a sys_id, not a string number but it might be worth checking your process here.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-05-2020 04:10 AM
i dont think there is column "change_request" available on rm_release table ,
if possible add some screenshot if you are seeing change_request column on rm_release table.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-05-2020 04:37 AM
Hi Harsha,
Yes there no field called change request.
even i have taken parent in the add query still its not working.
var gr=new GlideRecord('rm_release');
gr.addQuery('parent',current.sys_id);
gr.query();
gr.next();
if(gr.next()){
gr.parent=current.sys_id;
gr.update();
Thank You,
Sai.