19
Views
3
Comments
Solved
Check the last char of a string

Hi,


I have some database columns and I want to do a validation. I have 4 columns that I want to verify if any of these columns have this format some number between 0 and 100 and needs to end with a "%". This is a field to configure a css width using percentages, so a valid input should be for example "10%", "100%". Do you know how to properly achieve this in outsystems?

Thanks!

Rank: #2139
Solution

Hello Jake,


To retrieve the last character of a certain string you can use the following functions: 

I also added a little oml with the function in action, just enter something in the input field and it will show you the last character. All you need to do now is validate this in an action to get your desired result.


Kr,

Nick

teststring.oml

Rank: #956

Hi,


I think You colud use this Built-In Functions:


If(Substr(Var,Length(Var)-1,Length(Var))="%",True, False)

Where var is Your own variable.


KR,

Ivan

Rank: #2139
Solution

Hello Jake,


To retrieve the last character of a certain string you can use the following functions: 

I also added a little oml with the function in action, just enter something in the input field and it will show you the last character. All you need to do now is validate this in an action to get your desired result.


Kr,

Nick

teststring.oml

Hi! 

You can use some Built in functions 

- Lenght( t) - to know the lenght of the text t

- Substr(t, start, length)  -> Substring from t (note that the first character is in position 0 )

- TextToDecimalValidate()

- TextToDecimal(t) -> tranform a text in a Decimal value 

Stay safe

Graça