ITSM Catalog item

kali
Tera Contributor

Hi All,

I want to populate the variable's value which is inside the MRVS onto the onsubmit catalog client script , however i am not able to access the mrvs value from the onsubmit client script which applies to the catalog item.please help me on this

6 REPLIES 6

Ankur Bawiskar
Tera Patron

@kali 

you can grab the MRVS value in onSubmit catalog client script which Applies to Catalog Item and it gives you the JSON object

You can iterate over that and then grab the value

function onSubmit() {
    var mrvsValue = g_form.getValue('mrvsVariableSetName'); // give your MRVS variable set name here

    for (var i = 0; i < mrvsValue.length; i++) {
        var val = mrvsValue[i].userVariableName; // give here the variable name within MRVS
        alert(val);
    }

}

💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏

@kali 

Just following up to see whether my suggested solution worked for you.

If you're still facing any issues, I'd be happy to help further.

Chetna_Aggarwal
Tera Contributor

 

You can't directly access individual MRVS variable values from the parent catalog item's onSubmit Catalog Client Script.

Instead, retrieve the MRVS as JSON using g_form.getValue('<mrvs_variable_name>') and parse it.

 

 
var mrvs = JSON.parse(g_form.getValue('your_mrvs_name'));

for (var i = 0; i < mrvs.length; i++) {
    console.log(mrvs[i].your_variable_name);
}
 
 

If g_form.getValue() returns an empty value, please confirm whether you're using the Service Portal or the Native UI, as MRVS behavior differs slightly between them.