364
Views
4
Comments
Forcing two decimal places even if the value was ".00"
Question

Hello everyone,

I need help, I need to force two decimal places even if the value of the decimal was like this ".00".

Please see attached sample file below:

Here's some of my scenario:

Note: 1,2,3 is for the Client side. 4 and 5 is for the Core/Server side.

1. Here's the sample input file:


2. I have screen like this and in the Total Amount column I have value like that:


3. Here's the Expression Value of my Total Amount:


4. Here's the screen of my Core side/Server action:


5. Here's the output data on my table where the two decimal places ".00" doesn't effect on the table both client side and server side:

Thanks,
Ally

S1SMIC001.txt
2023-02-27 14-18-56
Jaya Kumar S

Hi @A L L Y

Use this mention  if it integer or decimal use  FormatDecimal(Value,2,".",",") or if it's text then 

FormatDecimal(TexttoDecimal(Value),2,".",",").

Hope it will work

Regards

Jaya Kumar S

2023-06-27 05-52-18
A L L Y

Hello @Jaya Kumar S,

I already try all the possible outcome/way but it didn't work. I appreciate your help!

Thanks,
Ally

2021-09-06 15-09-53
Dorine Boudry
 
MVP

Hi Ally,

where exactly do you want to see those .00 ? 

In the database, your totalamount attribute is defined as a decimal, not a text.  And you are looking at the data in the data tab of service studio.  However Outsystems feels like showing decimal values there is what you are going to see, that is not up to you to choose.  The value shown is correct.

You are at some point doing TextToDecimal(FormatDecimal(TextToDecimal.....) of some text value, in the hope of forcing something, but all you do is first transform the initial text value to a decimal, then formatting it to a text (at that point this formatted text will be of your desired appearance) and then turning that into a decimal again (no formatting)

again, where exactly do you want to see those .00, because that's the place where you should be doing your FormatDecimal(TotalAmount....).  For example, in UI where your data is shown to the end user, in an expression. 

So that's the one in your second image i think, that should be FormatDecimal(GetSLAInputFile.List.Current.SLAInputFile.TotalAmount, 2, ".", "").

You'll have to repeat this in every place in the UI that you are showing the TotalAmount in an expression.

Dorine

2019-09-11 10-03-50
Meer Imtiyaz Ali

Hi,

Please use this 

FormatCurrency(100, "", 2, ".", "") => 100.00

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.