access variable inside MRVS
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-10-2025 03:18 AM
Hi team,
I have a variable Requested for which is part of the User field variable set, and I have affected for the variable which is part of MRVS now i want to populate the affected for field with all users where manager is equal to requested for.
I tried creating a script include and calling it via ref qualifier but its returning undefined for current.variables.requested_for
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-10-2025 03:23 AM
Hello @vandanasaluja
Try my approach with exact script :-
1. Create a Catalog Client Script
-
Type:
onChange
-
Applies to Variable:
Requested For
-
UI Type:
All
orMobile / Service Portal
(based on usage) -
Script:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var requestedForSysId = g_form.getValue('requested_for');
var ga = new GlideAjax('GetUsersByManager');
ga.addParam('sysparm_name', 'getUsers');
ga.addParam('sysparm_manager', requestedForSysId);
ga.getXMLAnswer(function(response) {
var userList = JSON.parse(response);
g_form.clearMultiRowVariableSet('your_mrvs_variable_name'); // replace with actual MRVS name
for (var i = 0; i < userList.length; i++) {
var row = g_form.addNewMultiRow('your_mrvs_variable_name'); // replace with MRVS name
g_form.setValueInMultiRow(row, 'affected_for', userList[i].sys_id); // replace 'affected_for' with actual field name
}
});
}
2. Create a GlideAjax Script Include
-
Name:
GetUsersByManager
-
Set to Client Callable: true
var GetUsersByManager = Class.create();
GetUsersByManager.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getUsers: function() {
var managerId = this.getParameter('sysparm_manager');
var result = [];
var gr = new GlideRecord('sys_user');
gr.addQuery('manager', managerId);
gr.query();
while (gr.next()) {
result.push({
name: gr.getValue('name'),
sys_id: gr.getValue('sys_id')
});
}
return JSON.stringify(result);
}
});
Pls mark my solution as accept and thumbs up if you find it helpful. It will help other users on community to find helpful response.
Regards,
Samaksh Wani
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-10-2025 03:23 AM
Hello @vandanasaluja ,
Can you please share your script include
Thank you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-10-2025 03:26 AM
Use
g_service_catalog.parent.getValue("requested_for")
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-10-2025 03:32 AM
Tried but it didnot worked