The value of the field is not a valid number.

Discussions about Forms Designer for SharePoint 2013 / 2016 and Office 365.
Post Reply
TWendt
Posts: 109
Joined: Mon Sep 08, 2014

09 Oct 2020

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

User avatar
mnikitina
Posts: 263
Joined: Wed Jun 05, 2019

12 Oct 2020

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.

TWendt
Posts: 109
Joined: Mon Sep 08, 2014

13 Oct 2020

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 2272 times
Best wishes
Tom

User avatar
mnikitina
Posts: 263
Joined: Wed Jun 05, 2019

13 Oct 2020

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)));

TWendt
Posts: 109
Joined: Mon Sep 08, 2014

21 Oct 2020

Hi Mnikitina,

thanks your your assistance. It works perfect!

Best wishes
Tom

Post Reply
  • Information
  • Who is online

    Users browsing this forum: No registered users and 4 guests