How to update parent record using business rule

Sai25
Giga Guru

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();
}

find_real_file.png

Thank You,

Sai.

 

12 REPLIES 12

Mohit Kaushik
Mega Sage
Mega Sage

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

Thanks,
Mohit Kaushik
ServiceNow MVP (2023-2025)

Dubz
Mega Sage

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.

Harsh Vardhan
Giga Patron

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.  

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.