- 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 05:50 AM
Thanks Surya, that solution has worked for me.
Thanks to everyone else for your input as well, it's much appreciated
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-28-2017 04:27 AM
Use the below code
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.hasNext()) {
current.support_group = gr.u_support_group;
}
}
else{
current.support_group = current.contract.vendor.u_support_group;
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-28-2017 05:17 AM
Hi David,
I hope company is the reference field on the service offering form, so you have to pass the sys_id. If you want to still check with the name itself, use getDisplayValue() to get the name and there by add the condition as name.
if(current.contract.vendor.name == 'Liquid UK'){
var companyID = current.company; // Getting company sys_id Value
var gr = new GlideRecord('core_company');
gr.addQuery('sys_id', companyID);
gr.query();
while(gr.next())
current.support_group = gr.u_support_group;
}
else{
current.support_group = current.contract.vendor.u_support_group;
}