- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2017 04:15 AM
Afternoon All,
I'm on the service offering form and i want to update a reference field on here with the information contained in a reference field on the company form. I'm using a before insert business rule. What needs to happen is the support group on the service offering is set as the support group associated with a specific company when the service offering is inserted.
i've tried the below script and i've tried building up the variables but i can't seem to crack it. How do i grab that info from the company form and bring it back to my current form?
if(current.contract.vendor.name == 'Liquid UK'){
var gr = new GlideRecord('core_company');
gr.addQuery('name', 'Company Name i Need Info From');
gr.query();
while(gr.next());
current.support_group = gr.u_support_group;
}
else{
current.support_group = current.contract.vendor.u_support_group;
}
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2017 04:22 AM
Hello David,
Can you write this as on after business rule and write current.update();
if(current.contract.vendor.name == 'Liquid UK'){
var gr = new GlideRecord('core_company');
gr.addQuery('name', 'Company Name i Need Info From');
gr.query();
if(gr.next());
current.support_group = gr.u_support_group;
current.update();
}
else{
current.support_group = current.contract.vendor.u_support_group;
current.update();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2017 04:21 AM
This:
while(gr.next());
current.support_group = gr.u_support_group;
should be:
while(gr.next())
current.support_group = gr.u_support_group;
there's no ; after the while!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2017 04:22 AM
Hello David,
Use the below script and try.
var gr = new GlideRecord('core_company');
gr.addQuery('name', 'Company Name i Need Info From');
gr.query();
while(gr.next());
current.support_group = gr.u_support_group;
current.update():
}
ServiceNow Commnunity MVP -2018 class.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2017 04:27 AM
Don't do a current.update() in a before business rule. You can run into a loop.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2017 04:22 AM
Hello David,
Can you write this as on after business rule and write current.update();
if(current.contract.vendor.name == 'Liquid UK'){
var gr = new GlideRecord('core_company');
gr.addQuery('name', 'Company Name i Need Info From');
gr.query();
if(gr.next());
current.support_group = gr.u_support_group;
current.update();
}
else{
current.support_group = current.contract.vendor.u_support_group;
current.update();
}