- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-24-2024 07:18 AM
Hi All,
I have a requirement where i should auto populate Total Cost of all amount in $ field from Multi row Variable set.
What kind of Client script needs to be configured.
I have tried he solution below but it didn't work
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-25-2024 04:42 PM
Hello @dhanashree2011
I haven't tested the Willem solution but you can also try something using onSubmit() client script on catalog item which will calculate all the entries in the MRVS and append it to the variable in the catalog form. Use the below script if you want to implement with onSubmit.
function onSubmit() {
var totalAmount = 0;
var mrvsData = g_form.getValue('u_mrvs'); //give MRVS internal name
var mrvsParse = JSON.parse(mrvsData);
for (var i = 0; i < mrvsParse.length; i++) {
totalAmount += parseInt(mrvsParse[i].u_amount);
}
g_form.setValue("total_amount", totalAmount);
return false; //remove this after testing
}
Quick walk-through:
Hope it helps:)
Murthy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-25-2024 04:42 PM
Hello @dhanashree2011
I haven't tested the Willem solution but you can also try something using onSubmit() client script on catalog item which will calculate all the entries in the MRVS and append it to the variable in the catalog form. Use the below script if you want to implement with onSubmit.
function onSubmit() {
var totalAmount = 0;
var mrvsData = g_form.getValue('u_mrvs'); //give MRVS internal name
var mrvsParse = JSON.parse(mrvsData);
for (var i = 0; i < mrvsParse.length; i++) {
totalAmount += parseInt(mrvsParse[i].u_amount);
}
g_form.setValue("total_amount", totalAmount);
return false; //remove this after testing
}
Quick walk-through:
Hope it helps:)
Murthy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-28-2024 03:19 AM
Thanks.. This worked