Can you update Record Producer Variables from the submitted Record Fields
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2025 03:00 AM
Hi All
We courrently have a record producer where variables are mapped to fields on the table. We have had to map the varaibles to fields so that we can trigger notifications and also aid in reporting ( reporting is slow and time consuming when accessign the variables directly.
The end user is able to access their submitted ticket in the Portal and update their responses on each of the variables, which in turn updates the field values on the record ( which is correct)
What I would like to be able to do is if the value of the field on the submitted record changes, it then update the variable value to ben the same.
An example of the reasoning behind this is if a technician is veiwing mulitple tickets in list view, they could update multiple records in one go, which in turn would update the variable responses for each of those tickets. As it stands they would have to go into each ticket and update the variable in question.
I have tried with a the below business rule script, but it does not work:-
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2025 03:53 AM
you can use this syntax in after update business rule to update the variable value.
// query question_answer table with your record sysId against Table sys ID field and then update the Value column with the field value
(function executeRule(current, previous /*null when async*/ ) {
// Add your code here
var gr = new GlideRecord("question_answer");
gr.addQuery("table_sys_id", current.sys_id);
gr.query();
while (gr.next()) {
var mapField = question.field.toString(); // get the field name
gr.value = current[mapField]; // update the variable value by updating the value column
gr.update();
}
})(current, previous);
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2025 06:48 AM
Thanks for the reply Ankur, but nothing happens when it executes
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2025 06:52 AM
Did you add log and see if it ran?
any error?
If my response helped please mark it correct and close the thread so that it benefits future readers.
WELCOME
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2025 07:01 AM - edited 07-28-2025 07:03 AM
this is the updated code, I had a small mistake in above one, use this updated line
var mapField = gr.question.field.toString(); // get the field name
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader