How to access multi row variable set in client script?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-12-2019 08:30 AM
Hello All,
I want to compare MVRS 1st row fields data with 2nd & 3rd etc Row fields data, How could be possible, I have tried with below scripts but didn't get an expected result
function onLoad() {
//Type appropriate comment here, and begin script below
var mrvs = JSON.parse(g_form.getValue('variables.asset_details_and_costing_info'));
alert(mrvs.length);
alert(mrvs);
alert(mrvs[0].asset_type_requisition);
alert(mrvs.asset_type_requisition);
JSON.stringify(mrvs);
alert(mrvs.length);
alert(mrvs[1].asset_type_requisition);
alert(mrvs.asset_type_requisition);
var mrvs1 = JSON.parse(g_form.getValue('asset_details_and_costing_info'));
var getPrio = mrvs.map(function (mrvs1) {
return mrvs1.asset_type_requisition;
});
alert('array of priority ' + getPrio);
function dedup(arr) {
var servers = [];
var returnArr = arr.filter(function(row){
if(servers.indexOf(row.question_1)<0){
servers.push(row.question_1);
return row;
} else {
// row already entered
//console.log('row already exists with that variable');
}
});
return returnArr;
}
//console.log(JSON.parse(g_form.getValue("multirow_variable_set")));
console.log(g_form.getValue("asset_details_and_costing_info"));
var deduped = dedup(JSON.parse(g_form.getValue("asset_details_and_costing_info")));
console.log(deduped); // [ {a: 1}, [1, 2] ]
g_form.setValue("asset_details_and_costing_info",JSON.stringify(deduped));
}
I want to compare Asset Type row 1 data with row2 data, if both are not equal I want to show pop message to the end user saying that,
Please select same Asset Type for all rows
Thanks

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-12-2019 12:29 PM
Hi,
Why don't you write a onSubmit function and compare the data in the server script, which is easier to handle? Also when the data is added to the variables, the catalog item will not load. So your client script need to be on submit.
Or write a code in the server inside record producer and then throw an error if they are both same.
Mark the comment as a correct answer and also helpful if it helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-12-2019 09:15 PM
Hi Asif,
Thanks for the reply, Here my client requirement is to compare on the fly with 2nd row data instead of filling all the rows and submission of request later
Thanks

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-13-2019 05:21 AM
Harish,
Onsubmit catalog client scripts or ui policies does not work with multi row variable sets. hence you need to use server side scripts to validate.
Mark the comment as a correct answer and helpful if it answers your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-13-2019 07:00 AM
Hi Harish
Is your question got resolved ? If not please let me know
please check if the below links are helpful
https://www.youtube.com/watch?v=K4wvIzfv7eo
https://www.youtube.com/watch?v=wvByy41G7Zk
Best regards
Rajesh Kumar Annepaka