Hi
I a wanting to use FormatDecimal since I want the formatting options that that has, but I want to show a MAX of 8 decimals and a MIN of 0... i.e. I don't want to show always 8 decimals which is what this currently does - I want it to show the actual number of decimals up to 8.
Data is coming from an aggregate straight into an input so ideally want something that can not create extra steps... i.e. not regex SQL etc. but I am open to all and any suggestions. Ideally looking for something built into OutSystems.
Hi Nicholas,
Regex that I suggested is indeed a server action, but the concept of regex can be applied in any programming language. In this case, it can be easily applicable in javascript too.
Javascript has replace function that you can use in a small function with 2 inputs, string and regex and 1 output to return your string. This can easily do the job, with zero overhead on the server as you would be using only the client side scripting for processing.
https://www.freecodecamp.org/news/javascript-string-replace-example-with-regex/
Is your data coming from the aggregate is decimal type or string?
Try something like this:
https://www.outsystems.com/forums/discussion/55585/removing-leading-zeroes-from-text-variable/
You can resolve your text manipulation operation quickly using Regex.
If you use Advanced SQL instead of data aggregates, you can get more flexibility around using SQL functions.
this is an input, so user can edit ?
I think you'd have to look at one of the inputmask forge components for this.
for example InputMask React has boolean option AlwaysShowDecimalDigits
Dorine
Hi Dorine
This is unfortunately in a table so I can't use those. I have used those for other inputs though which have done the trick.
Hi Ravi, this will work, but looking for something simpler - using Regex_Replace I would need to add a step to do that in an action since you can't apply that directly into an Expression or in a Client action (since it is a server action) (from what I can see) like you can with FormatDecimal. I don't want to use AdvancedSQL for this either.
Any other ideas? Basially I want something like Trim but not with ' ' but with '0'... any ideas?
Thinking of rather using regex within Client action using JavaScript might be the best option for my case?
Thanks Ravi, appreciate the assiatance.
I used the following inside of a JS widget for anyone else seeing this post:
'VariableName'.replace(/^([\d,]+)$|^([\d,]+)\.0*$|^([\d,]+\.[0-9]*?)0*$/, "$1$2$3");