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

Kieran Anson
Kilo Patron

Hi,

What is the field type of mrvs_data, and what is the expected result? A comma seperated string of full-names?

Hi, mrvs_data is Single line text type variable and we want to push the data with comma-separated names.

Thanks!

I would move your logic to run as part of the fulfilment process (workflow or flow). What is this field's data being used for?

It's a hidden variable and it is not visible anywhere in catalog form/RITM/TASK, the purpose of this variable is to reuse this variable in different places.