Page 1 of 1

The value of the field is not a valid number.

Posted: 09 Oct 2020
by TWendt
Hello,

when I use the following script in MS Edge, Google Chrome or Firefox

//Calculate Consulting
var total = 0;
var rows = fd.relatedItems(4).data('ctx').ListData.Row;
rows.forEach(function(item) {
total += parseFloat(item['Kosten.'])
total_overall += parseFloat(item['Kosten.'])
});
fd.field('Kosten_x0020_Beratungsaufwand_x0').value(Number(total.toFixed(2)).toLocaleString("de-DE", {style: "currency", currency: "EUR"}));

an error occured in the field Kosten_x0020_Beratungsaufwand_x0 when I save

The value of the field is not a valid number.

What is wrong?

Best wishes
Tom

Re: The value of the field is not a valid number.

Posted: 12 Oct 2020
by mnikitina
Hello Tom,

What type are the Kosten_x0020_Beratungsaufwand_x0 field and Kosten column?

Could you please share the screenshot of the form so I could have the full picture.

Re: The value of the field is not a valid number.

Posted: 13 Oct 2020
by TWendt
Hello mnikitina,

the type of the fields Kosten_x0020_Beratungsaufwand_x0 and Kosten are currency in Euro.
Not_a_valid_number.JPG
Not_a_valid_number.JPG (24.3 KiB) Viewed 7936 times
Best wishes
Tom

Re: The value of the field is not a valid number.

Posted: 13 Oct 2020
by mnikitina
Hello Tom,

Thank you for the information!

The currency field type accepts only numbers. The currency sign displayed in a list view and on the display form only.

Thus, please remove the toLocaleString function from the code:

Code: Select all

//Calculate Consulting
var total = 0;
var rows = fd.relatedItems(4).data('ctx').ListData.Row;
rows.forEach(function(item) {
total += parseFloat(item['Kosten.'])
total_overall += parseFloat(item['Kosten.'])
});
fd.field('Kosten_x0020_Beratungsaufwand_x0').value(Number(total.toFixed(2)));

Re: The value of the field is not a valid number.

Posted: 21 Oct 2020
by TWendt
Hi Mnikitina,

thanks your your assistance. It works perfect!

Best wishes
Tom