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 08:17 PM
Hope you are doing good.
Did my reply answer your question?
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-29-2025 03:27 AM
Morning Ankur,
Thansk for the revised code, but it is still not working as expected. If I change the value on the record, both mapped and unmapped variables update to "undefined".
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-29-2025 03:37 AM
Did you add log and debug in that business rule?
without that you know where it's breaking
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 04:00 AM
Hi @jonathangilbert ,
Variables will be stored in sc_item_option_mtom table. Please use below script to update the variable.
(function executeRule(current, previous /*null when async*/) {
// Only run if the location field has changed
if (current.location != previous.location) {
// Get the variable definition by name
var variableName = 'wh_location_of_where_accident_happened'; // sys_name of the variable
var varDef = new GlideRecord('item_option_new');
varDef.addQuery('name', variableName);
varDef.addQuery('cat_item', current.cat_item); // Optional, to be precise
varDef.query();
if (varDef.next()) {
// Find the variable response record (option mtom)
var varValue = new GlideRecord('sc_item_option_mtom');
varValue.addQuery('request_item', current.sys_id);
varValue.addQuery('sc_item_option', varDef.sys_id);
varValue.query();
if (varValue.next()) {
varValue.value = current.location;
varValue.update();
}
}
}
})(current, previous);