how to trim the number?

0
I have material number which consists of 15 digits with starts with 9 zero’s,so while displaying i want to trim the zeros and should display the remaining number
asked
3 answers
1

I don’t know your context, but I think in this case it is not bad to add a “technical” integer attribute to your entity like _MaterialNumber. The value of this attribute is your material number parsed to an integer (use the function parseInteger).

Consider to use an event like an OnChange to set the _MaterialNumber attribute value correctly. So you have no need to do this for each display (better performance). In your view you can use _MaterialNumber to show without leading zeros. And you still have the original attribute available. 

answered
1

You can use the replaceAll function to strip leading zeros. This function accepts regular expressions. So, you can tell it to remove leading zeros with something like this:

replaceAll(MaterialNumber, '^0+', '')

 

answered
0

If this is always true you could have a quick solution by parsing it to Integer, removing the leading zero’s and then back to String or Decimal*

For some documentation on the matter see: 
parseInteger → https://docs.mendix.com/refguide/parse-integer
toString → https://docs.mendix.com/refguide7/to-string 

answered