In a Record Producer how to sum the amount(currency) field in list of records in the list selector?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-05-2024 07:44 AM
I have created a Record Producer which contains list collector field called "Expense Items"
Expense Items are a records of a table which has "amount" as a field(currency);
How can I get the "amount" of the selected list of expense items and total it to a field(Total Amount) on Record Producer itself before submitting it.
And the "Total Amount" should populate in a form called Expense Report which contains "Sum" field(currency) that is mapped to the above Record producer?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-05-2024 07:55 AM
check this:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue === '') {
return;
}
var items = g_form.getReference('expense_items').split(',');
var totalAmount = 0.0;
items.forEach(function(item) {
var amount = parseFloat(g_form.getValue('expense_items.amount', item));
if (!isNaN(amount)) {
totalAmount += amount;
}
});
g_form.setValue('total_amount', totalAmount.toFixed(2));
}
----------------------------------------
If my response was useful, please mark as "Accept as Solution" and " Helpful." This action benefits both the community and me.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-08-2024 10:44 PM
Error: There is a JavaScript error in your browser console.
Can we do it without getReference?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-05-2024 07:55 AM
Hi @Joshua Prakash,
please check below link:
Thank you, please make helpful if you accept the solution.