- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-14-2022 07:38 AM
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
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-14-2022 08:22 AM
@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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-14-2022 07:52 AM
If you are trying to insert a new record into the guest table, use this in your record producer script.
var gr = new GlideRecord('guestTableName'); // set your table name
gr.initialize();
gr.firstNameFieldName = producer.variableNameForFirst; // update with the correct variable & column names
gr.lastNameFieldName = producer.variableNameForLast; // update with the correct variable & column names
gr.middleNameFieldName = producer.variableNameForMiddle; // update with the correct variable & column names
gr.insert();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-14-2022 07:52 AM - edited 11-14-2022 07:52 AM
hello @rajasekar reddy ,
You can use record producer script by gliding your custom table and updating your record like below.
Write this below script in record producer script field
var gr = new GlideRecord('your_custom_table');
gr.addQuery('your_field_name','value');
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();
}
Hope this helps
Mark the answer correct if this helps you in any way
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-14-2022 08:13 AM
Hey Mohith, what should be the field name and value in second line of script. I need to update only 3fields from 3 varibles
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-14-2022 08:22 AM
@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