I want to change the variable (single line text ) in MVRS on change of variable in catalog item
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-12-2025 12:07 PM
I want to change the variable (single line text ) in MVRS on change of variable in catalog item.
can anyone suggest something
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-12-2025 09:51 PM
so variable within MRVS should change based on outside variable?
If yes then use this logic to access the outside variable in client script which applies to MRVS
sharing here as well
You can access the variables with this syntax. This works in both Native + Portal
var applicationType = g_service_catalog.parent.getValue("variableName");
Example: I have used an onLoad catalog client script which applies to MRVS and it gave me the value of outside variable when the MRVS form was loaded.
Client Script:
Output in Native:
Output in Portal:
I created blog for the same recently
Access value of catalog item variable within MRVS client script
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
03-12-2025 11:24 PM
Hi @sariksorte , you may try the following:
- Create an onChange client script for the catalog item, where the field change variable is the one whose value change should trigger an update in a single-line text variable inside the MRVS.
- Within the same onChange client script, you can update the rows accordingly.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
//Type appropriate comment here, and begin script below.
var mrvs = JSON.parse(g_form.getValue('mrvs')); //your MRVS name
var rows = mrvs.length;
if (rows > 0) {
for (var i = 0; i < mrvs.length; i++) {
mrvs[i].single_line_variable = 'Value you need to update';
}
g_form.setValue('mrvs', JSON.stringify(mrvs));
alert(rows + ' rows affected by the change in the "Requested For" field value.');
}
}
- Please see the results, if this is what you are expecting?
One more question: Are you trying to update a specific row based on certain conditions, or do you need to update all rows inserted so far?