In Application Studio, by sending a grid as a parameter to a function (System.Data.Dataset), my decimal numbers that are editeable convert to an int and are rounded

I don’t understand at all why it’s happening. I tried changing my mask (Which was >>>,>>>,>>>,>>9.99 before I removed any mask and only set the erp editor configuration of the column to ‘Number’) and everything I could (BAQ format, tried converting to string and to format in the function) but nothing works. Did this happened to anyone else?

Input:
image

Output (I simply set ds2 = ds in my function)
image

Here is what I entered in my grid:

Have you ever figured this out?

I actually know why it is happening, but the only workaround I could find is to set the Grid columns as strings instead of numbers.

This happens if you pass a whole dataset with multiple rows. Then the json will be passed to the ERP function. But if your first row has integer values, then the datatype in the System.Data.Dataset will be Integer, so the same column of the other rows will be cast as int.

There should be a way to define the Datatypes in the function, or to send a JSON Schema along with the REST Request… I hope one of these features will be added in the near future

I haven’t found a fix yet. The only workaround I had was to duplicate my function and instead of having a Dataset parameter (the grid), I have one parameter for each column (Job, Qty, Cost, etc.). In my application studio app, I use the dataview-condition action to iterate my rows and then call the function for each row

Not perfect but it works

Thanks for your reply.

If you ever want to send All Rows at the same time. Here’s how I fixed mine:

  • Set the grid column data type as Text
  • In your function, you can do this:
using System.Globalization;
bool parseOk = decimal.TryParse(StringColumn, NumberStyles.Any, CultureInfo.InvariantCulture, out decimal ConvertedString);
  • do something if parseOk is false

The NumberStyles.Any and CultureInfo.InvariantCulture is to make sure that you can either send “100.2”, or “100,2” without errors regardless of your current Culture.

1 Like