Help with Record Producer script

jlaue
Mega Sage

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!

1 ACCEPTED SOLUTION

Mark Roethof
Tera Patron

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).

find_real_file.png

If my answer helped you in any way, please then mark it as helpful.

Kind regards,
Mark

---

LinkedIn

View solution in original post

6 REPLIES 6

Mark Roethof
Tera Patron

Hi there,

What actually is not working? Have you tried producer.variables.yourvarname instead of current.variables.yourvarname.

Kind regards,
Mark

---

LinkedIn

Mark Roethof
Tera Patron

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

Mark Roethof
Tera Patron

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).

find_real_file.png

If my answer helped you in any way, please then mark it as helpful.

Kind regards,
Mark

---

LinkedIn

Prateek kumar
Giga Sage

Instead of current.variables.variable_name you should use producer.variable name

https://old.wiki/index.php/Record_Producer