Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How to set the variable value with the MRVS reference variable data

kumar22
Tera Contributor

Hi Team,

I have a requirement below :

Catalog item variable: MRVS data(mrvs_data)

Multi-Row variable set: Mobile Devices Set (mobile_devices_set)

kumar22_0-1716875705193.png

Once the request gets submitted I need to pass the Approval User (approval_user) data to the MRVS data(mrvs_data) variable. I tried using the OnSubmit client script below but it returned the sys_id instead of User ID.

 

function onSubmit() {
var deviceSet = g_form.getValue("mobile_devices_set");
    var str = JSON.parse(deviceSet);
    var appUserArray = [];
    for (var i = 0; i < str.length; i++) {
        //var num = i + 1;
        appUserArray.push(str[i].approval_user);
    } 
    var approvalUser = appUserArray.join(' , ');
    g_form.setValue("mrvs_data", approvalUser);   
}

Kindly suggest on this? 

Thanks in advance.

11 REPLIES 11

@kumar22 

you can use script to get, parse MRVS and set in outside variable

what did you start with?

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

I tried with the below OnSubmit client script but the reference field value giving sys_id instead name.

function onSubmit() {
var deviceSet = g_form.getValue("mobile_devices_set");
    var str = JSON.parse(deviceSet);
    var appUserArray = [];
    for (var i = 0; i < str.length; i++) {
        //var num = i + 1;
        appUserArray.push(str[i].approval_user);
    } 
    var approvalUser = appUserArray.join(' , ');
    g_form.setValue("mrvs_data", approvalUser);   
}