ITSM Catalog item
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi @kali ,
If you're trying to access a value from a Multi-Row Variable Set (MRVS) in an onSubmit Catalog Client Script, you can retrieve the MRVS value using g_form.getValue() and then parse the returned JSON.
For example:
function onSubmit() {
var mrvsValue = g_form.getValue('your_mrvs_name');
if (mrvsValue) {
var rows = JSON.parse(mrvsValue);
for (var i = 0; i < rows.length; i++) {
var value = rows[i].your_variable_name;
console.log(value);
}
}
return true;
}Make sure you use the MRVS internal name with g_form.getValue(), and inside each row use the internal name of the variable, not its label.
If you need to populate another catalog variable based on a value inside the MRVS, you can extract the required value first and then use g_form.setValue() before returning true.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 weeks ago
Hi @kali,
You can access the values of variables inside an MRVS from the Catalog Item onSubmit Catalog Client Script by using g_form.getValue() to retrieve the MRVS data and then parsing the returned JSON.
function onSubmit() { var mrvs = g_form.getValue('your_mrvs_name'); if (mrvs) { var mrvsData = JSON.parse(mrvs); for (var i = 0; i < mrvsData.length; i++) { alert(mrvsData[i].your_variable_name); } }}
Please note:
- Replace your_mrvs_name with the Name of your MRVS.
- Replace your_variable_name with the Name of the variable inside the MRVS.
- g_form.getValue() returns the MRVS data as a JSON string.
- JSON.parse() converts the JSON string into an array, allowing you to access each row and its variables.
I hope this helps! If this solution resolves your issue, please consider marking this answer as Correct.