Hi, is there anybody who can help me with the following?

Is there a built in function to do a check on an input value.

For example I fill in the following in an inputfield "Street"

The check that I would like to have is if the inputfield consist the letter "t" than an error should be displayed.


Thanks in advance!

Hi António,

You can use the "Regex_Search" Server action. You can find this action under the "Text" extension. This action lets you give a text as an input together with a pattern you want to look for in your text. If this pattern consists in your input, the Regex_Search returns True. Otherwise it will return false. The regex you probably want to use is [t]

Regards,

Tyler

Solution

Hi!

Try the .oml 

You use the OnChange Event in the Input widget to trigger a screen action where you can look at the content of the input string and figure out if there are is a 't' in it.

To look for the 't' you can use Index or Regex.

Hope it helps!

Solution

Hi Antonio,

Please use the regex option to achieve this functionality provided by Outsystems, you can find it in reference Text module.

Regards,

Manish Jawla

Hi Antonio,

If you don't want to use regex and need simple text match then you can use Index text method. Check below image to see how it works:

If returned value is -1 it means your search term is not present in text so you can set valid property of the input to false and set validation message.

Thanks for all the replies.

I managed to make this work using just the Index text method. But i also wanted to use this for another situation. But it doesnt work for the situation below.

Situation:

I have an attribute Amount with datatype Currency. When i try so save an amount with a value consisting a "," (example 50,95) i get a standard validation message "Currency Expected" This is caused because a Currency datatype expects a "." and not a ",".

I thought I could overrule this message by using the same indext text method

SyntaxEditor Code Snippet

Index(VariableForm.Record.Variable.Variable,",") = -1

But it looks like my own code is being overruled by the Outsystems Currency Validation. Is there a way I can overrule this?

Thanks again!

Nikhil Gaur wrote:

Hi Antonio,

If you don't want to use regex and need simple text match then you can use Index text method. Check below image to see how it works:

If returned value is -1 it means your search term is not present in text so you can set valid property of the input to false and set validation message.


Thanks for all the replies.

I managed to make this work using just the Index text method. But i also wanted to use this for another situation. But it doesnt work for the situation below.

Situation:

I have an attribute Amount with datatype Currency. When i try so save an amount with a value consisting a "," (example 50,95) i get a standard validation message "Currency Expected" This is caused because a Currency datatype expects a "." and not a ",".

I thought I could overrule this message by using the same indext text method

SyntaxEditor Code Snippet

Index(VariableForm.Record.Variable.Variable,",") = -1

But it looks like my own code is being overruled by the Outsystems Currency Validation. Is there a way I can overrule this?

Thanks again!


Processing Upload...

António Neves wrote:

Nikhil Gaur wrote:

Hi Antonio,

If you don't want to use regex and need simple text match then you can use Index text method. Check below image to see how it works:

If returned value is -1 it means your search term is not present in text so you can set valid property of the input to false and set validation message.


Thanks for all the replies.

I managed to make this work using just the Index text method. But i also wanted to use this for another situation. But it doesnt work for the situation below.

Situation:

I have an attribute Amount with datatype Currency. When i try so save an amount with a value consisting a "," (example 50,95) i get a standard validation message "Currency Expected" This is caused because a Currency datatype expects a "." and not a ",".

I thought I could overrule this message by using the same indext text method

SyntaxEditor Code Snippet

Index(VariableForm.Record.Variable.Variable,",") = -1

But it looks like my own code is being overruled by the Outsystems Currency Validation. Is there a way I can overrule this?

Thanks again!


I have to say I have never used the type Currency before, I was always told to use Decimal instead.

try this:

Look in the .oml I attached, you can use a text variable in the input, split it into left side (natural numbers) and right side (decimal numbers) and join them with a dot in the middle, this way both ',' and '.' work .

Also this is a great exercise to learn how to use data types in outsystems!


Filipe Silva wrote:

António Neves wrote:

Nikhil Gaur wrote:

Hi Antonio,

If you don't want to use regex and need simple text match then you can use Index text method. Check below image to see how it works:

If returned value is -1 it means your search term is not present in text so you can set valid property of the input to false and set validation message.


Thanks for all the replies.

I managed to make this work using just the Index text method. But i also wanted to use this for another situation. But it doesnt work for the situation below.

Situation:

I have an attribute Amount with datatype Currency. When i try so save an amount with a value consisting a "," (example 50,95) i get a standard validation message "Currency Expected" This is caused because a Currency datatype expects a "." and not a ",".

I thought I could overrule this message by using the same indext text method

SyntaxEditor Code Snippet

Index(VariableForm.Record.Variable.Variable,",") = -1

But it looks like my own code is being overruled by the Outsystems Currency Validation. Is there a way I can overrule this?

Thanks again!


I have to say I have never used the type Currency before, I was always told to use Decimal instead.

try this:

Look in the .oml I attached, you can use a text variable in the input, split it into left side (natural numbers) and right side (decimal numbers) and join them with a dot in the middle, this way both ',' and '.' work .

Also this is a great exercise to learn how to use data types in outsystems!


I found an even better way of doing it!

Use a Text variable in the input, use Replace() to switch the ',' and '.' and use a cast to Decimal.

Very easy! Check the .oml



Filipe Silva wrote:

Filipe Silva wrote:

António Neves wrote:

Nikhil Gaur wrote:

Hi Antonio,

If you don't want to use regex and need simple text match then you can use Index text method. Check below image to see how it works:

If returned value is -1 it means your search term is not present in text so you can set valid property of the input to false and set validation message.


Thanks for all the replies.

I managed to make this work using just the Index text method. But i also wanted to use this for another situation. But it doesnt work for the situation below.

Situation:

I have an attribute Amount with datatype Currency. When i try so save an amount with a value consisting a "," (example 50,95) i get a standard validation message "Currency Expected" This is caused because a Currency datatype expects a "." and not a ",".

I thought I could overrule this message by using the same indext text method

SyntaxEditor Code Snippet

Index(VariableForm.Record.Variable.Variable,",") = -1

But it looks like my own code is being overruled by the Outsystems Currency Validation. Is there a way I can overrule this?

Thanks again!


I have to say I have never used the type Currency before, I was always told to use Decimal instead.

try this:

Look in the .oml I attached, you can use a text variable in the input, split it into left side (natural numbers) and right side (decimal numbers) and join them with a dot in the middle, this way both ',' and '.' work .

Also this is a great exercise to learn how to use data types in outsystems!


I found an even better way of doing it!

Use a Text variable in the input, use Replace() to switch the ',' and '.' and use a cast to Decimal.

Very easy! Check the .oml



Hi Filipe,

Thanks again for your reply. Im familiar with the replace method. Well since last week :)

And I know this is also a possible solution. But i wanted also to know how I could overrule the standard outsystems validation message with my own message


António Neves wrote:

Filipe Silva wrote:

Filipe Silva wrote:

António Neves wrote:

Nikhil Gaur wrote:

Hi Antonio,

If you don't want to use regex and need simple text match then you can use Index text method. Check below image to see how it works:

If returned value is -1 it means your search term is not present in text so you can set valid property of the input to false and set validation message.


Thanks for all the replies.

I managed to make this work using just the Index text method. But i also wanted to use this for another situation. But it doesnt work for the situation below.

Situation:

I have an attribute Amount with datatype Currency. When i try so save an amount with a value consisting a "," (example 50,95) i get a standard validation message "Currency Expected" This is caused because a Currency datatype expects a "." and not a ",".

I thought I could overrule this message by using the same indext text method

SyntaxEditor Code Snippet

Index(VariableForm.Record.Variable.Variable,",") = -1

But it looks like my own code is being overruled by the Outsystems Currency Validation. Is there a way I can overrule this?

Thanks again!


I have to say I have never used the type Currency before, I was always told to use Decimal instead.

try this:

Look in the .oml I attached, you can use a text variable in the input, split it into left side (natural numbers) and right side (decimal numbers) and join them with a dot in the middle, this way both ',' and '.' work .

Also this is a great exercise to learn how to use data types in outsystems!


I found an even better way of doing it!

Use a Text variable in the input, use Replace() to switch the ',' and '.' and use a cast to Decimal.

Very easy! Check the .oml



Hi Filipe,

Thanks again for your reply. Im familiar with the replace method. Well since last week :)

And I know this is also a possible solution. But i wanted also to know how I could overrule the standard outsystems validation message with my own message


In the action handling the OnChange event, assign the ValidationMessage property of the widget


Did you solve it? 

Don't forget to mark solutions so that other people can see this in the future

I also appreciate the community points :)

Filipe Silva wrote:

Did you solve it? 

Don't forget to mark solutions so that other people can see this in the future

I also appreciate the community points :)

Hi Filipe,

Well in general the index and regex, both methods seems to be a solution to my initial question.

But this doesnt work when using a Datatype Currency and when you are looking for a ","

I solved this by making it impossible to fill the inputfield with a ","

Thanks for your help Filipe!