- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2024 02:45 PM
Hey everyone,
I have created a MRVS and am attempting to get the values to populate based on the selection. I have several items with different values, I am trying to get it to populate the depreciated_item_value variable with the cost for which ever item is selected. Then multiply that depreciated_item_value by the quantity and populate into the donation_value variable. I have tried a few catalog client scripts but am not having much luck, any help would be greatly appreciated! I will post some pictures for reference.
Thanks,
Jonathan
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2024 10:10 PM
Hi @jonsr20
Refer below steps and configure your client scripts accordingly :
1. To Auto-populate Depreciated Item Value, make use of below Client Script :
function onChange(control, oldValue, newValue, isLoading) {
function getValue() {
var value = g_form.getValue('donation');
value = value.split('$');
g_form.setValue('depreciated_item_value', value[0]);
}
if (isLoading || newValue == '') {
getValue();
return;
}
//Type appropriate comment here, and begin script below
getValue();
}
2. To Auto-Populate Donation Value based on quantity change, make use of below On-Change Client Script :
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
//Type appropriate comment here, and begin script below
var quantity = g_form.getValue('quantity');
var itemValue = g_form.getValue('depreciated_item_value');
var donationValue = itemValue*quantity;
g_form.setValue('donation_value',donationValue);
}
Output :
Thanks and Regards
Amit Verma
Please mark this response as correct and helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2024 06:41 PM
Hi @jonsr20 ,
Can you share your client scripts please?
If my response helped you, please click on "Accept as solution" and mark it as helpful.
- Saloni
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2024 08:46 PM
Hi @jonsr20 ,
Please follow this article: https://www.servicenow.com/community/developer-articles/set-values-in-a-multi-row-variable-set-mrvs/...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2024 10:10 PM
Hi @jonsr20
Refer below steps and configure your client scripts accordingly :
1. To Auto-populate Depreciated Item Value, make use of below Client Script :
function onChange(control, oldValue, newValue, isLoading) {
function getValue() {
var value = g_form.getValue('donation');
value = value.split('$');
g_form.setValue('depreciated_item_value', value[0]);
}
if (isLoading || newValue == '') {
getValue();
return;
}
//Type appropriate comment here, and begin script below
getValue();
}
2. To Auto-Populate Donation Value based on quantity change, make use of below On-Change Client Script :
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
//Type appropriate comment here, and begin script below
var quantity = g_form.getValue('quantity');
var itemValue = g_form.getValue('depreciated_item_value');
var donationValue = itemValue*quantity;
g_form.setValue('donation_value',donationValue);
}
Output :
Thanks and Regards
Amit Verma
Please mark this response as correct and helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-21-2024 05:20 AM
Thank you so much for your response, I got that to work! You guys are the best!!!
Thanks,
Jonathan