- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-27-2023 01:16 AM
function onSubmit() {
var totalAmount = 0;
var gr = JSON.parse(g_form.getValue('name_of_mrvs'));
for (var i = 0; i < gr.length; i++) {
var subtotal = gr[i].subtotalamount;
var subtotalNum = parseFloat(subtotal);
if (!isNaN(subtotalNum)) {
totalAmount += subtotalNum;
} else {
console.log('Invalid number at row ' + i);
}
}
console.log('Calculated Total Amount:', totalAmount); // Console Log
// Populate result in u_totalamount
console.log('Setting u_totalamount to:', totalAmount); // Console Log
g_form.setValue('u_totalamount', totalAmount);
console.log('u_totalamount set successfully'); // Console Log
};
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-27-2023 05:04 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-27-2023 01:19 AM
Hi there,
What do you exactly mean with corresponding value in task? Do you have a field added on task? Or are you quering task.variables.your_variable?
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-27-2023 05:04 PM
Sorry, I solved it myself.
This script was running correctly.