Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Map variable to different table

rajasekar reddy
Tera Contributor

Hi experts,

we have created variables called 'firstname', 'last name' & 'middle name' in a variable set of a record producer.

Our record producer creates a record in incident table.  We have custom fields 'firstname', 'last name' & 'middle name' on Incident table and guest table (custom table).

My requirement is when record producer is submitted, we need to update 'firstname', 'last name' & 'middle name' both in incident and guest tables.

For incident, I have mapped the fields and it is working fine. But how can I update custom table fields.

 

Can someone help.  TIA

 

1 ACCEPTED SOLUTION

@rajasekar reddy it need not be any field because second line is to filter the records that you want to update .

Lets say if you want to update a particular record with active as true so you can write like 

 

var gr = new GlideRecord('your_custom_table');
gr.addQuery('active',true);
gr.query();
if(gr.next())
{
gr.your_first_name_field_backend_name = producer.your_first_name_variable_backend_name;
gr.your_last_name_field_backend_name = producer.your_last_name_variable_backend_name;
gr.your_middle_name_field_backend_name = producer.your_middle_name_variable_backend_name;
gr.update();
}

Like this as per your requirement if you have any particular records  to be updated in your custom table then build a query accordingly just like the above .

 

Mark the answer correct if this helps you

View solution in original post

6 REPLIES 6

@rajasekar reddy did the above script work ?

if yes mark the answer correct and close the thread so that it benefits future readers

Hi Mohith,

 

I have a similar requirement and cannot get the script to work. My record producer's table is x_nuvo_eam_elocation (Location), however the Location record has a field (Reservable) that is not in the Location table's dictionary and resides in x_nuvo_eam_space (Space). 

I have tried 2 methods but neither work. Any help would be greatly appreciated, thanks.

  1. current.space.reservable = producer.reservable;
  2. revising your script:
var gr = new GlideRecord('x_nuvo_eam_space');
gr.addQuery('active',true);
gr.query();
if(gr.next())
{
gr.reservable = producer.reservable;
gr.update();