- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-19-2019 12:29 PM
Hello -
I am trying to get a Service Catalog Record Producer. I need to insert a record into 2 other tables with variables from the record producer. I have included what I thought may work, but unfortunately is not working. I am not sure if this is even possible to do it this way from within the Record Producer script box. Here is what I have, any help is greatly appreciated!
//add the Vendor Contact
var gr = new GlideRecord('vm_vendor_contact');
gr.initialize();
gr.name = current.variables.contact_name;
gr.type = current.variables.type;
gr.primary_phone = current.variables.office_phone;
gr.alternate_phone = current.variables.mobile_phone;
gr.fax = current.variables.contact_fax;
gr.title = current.variables.title;
gr.address = current.variables.address;
gr.email = current.variables.email;
gr.company = current.variables.name;
gr.insert();
//add NDA Contract
if (current.variables.request_a_nda == 'yes'){
var gr = new GlideRecord('ast_contract');
gr.initialize();
gr.u_requested_for = current.variables.requested_for;
gr.contract_model = current.variables.contract_model;
gr.short_description = current.variables.brief_description;
gr.vendor = current.variables.name;
gr.insert();
}
Thank you!
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-19-2019 12:42 PM
Just tested and confirmed: producer.your_var_name works fine. gr.insert() is also no issue. I just created an Incident (thru the Record Producer) and a Change Request (thru the Script).
If my answer helped you in any way, please then mark it as helpful.
Kind regards,
Mark
---
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-19-2019 12:35 PM
Hi there,
What actually is not working? Have you tried producer.variables.yourvarname instead of current.variables.yourvarname.
Kind regards,
Mark
---
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-19-2019 12:38 PM
Just looking at one of the Record Producers (i assume you mean Record Producers, script field), and you can just use producer.your_variable_name.
Kind regards,
Mark
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-19-2019 12:42 PM
Just tested and confirmed: producer.your_var_name works fine. gr.insert() is also no issue. I just created an Incident (thru the Record Producer) and a Change Request (thru the Script).
If my answer helped you in any way, please then mark it as helpful.
Kind regards,
Mark
---
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-19-2019 12:42 PM
Instead of current.variables.variable_name you should use producer.variable name
https://old.wiki/index.php/Record_Producer
Please mark my response as correct and helpful if it helped solved your question.
-Thanks