Regex server action in mobile offline scenario

Hi,

I have a requirement where I have to display validation message which will be like, 15 values before decimal and 3 values after decimal. For this I have used Regex Server action which is working fine for online, but throwing error in offline. My doubt is can't we use Regex in offline scenario. Is there any other way to do this validation. 


Thanks & Regards,

Melody

Hi Melody,


The Regex action you are using is a server action. All server actions demand a request to the server and they will work only online. To do the same task in offline you need to use client actions and/or javascript code to do the regular expressions.

There is a component in the forge called Mobile Utilities that already implements this in the client side. This component should work in your scenario. https://www.outsystems.com/forge/Component_Overview.aspx?ProjectId=1730 


Best Regards

Fabio Fantato




Fábio Fantato wrote:

Hi Melody,


The Regex action you are using is a server action. All server actions demand a request to the server and they will work only online. To do the same task in offline you need to use client actions and/or javascript code to do the regular expressions.

There is a component in the forge called Mobile Utilities that already implements this in the client side. This component should work in your scenario. https://www.outsystems.com/forge/Component_Overview.aspx?ProjectId=1730 


Best Regards

Fabio Fantato




Hi Fabio

Thanks for the reply. Is there any outsystems supported component.

Thanks & Regards

Melody


Hi Melody,

There is not. You shouldn't be scared by the warnings in the Forge though, the fact it isn't OS supported does not mean you can't safely use the component. However, you can easily look at the source code of that component, and just use the RegEx.

You could also easily create your own with a Client Action with a JavaScript Statement:

var regExp = new RegExp($parameters.RegEx, $parameters.Options);
var result = $parameters.Input.match(regExp);
if (result !== null) {
    $parameters.Result = result[0];
    $parameters.IsMatch = true;
}



Kilian Hekhuis wrote:

Hi Melody,

There is not. You shouldn't be scared by the warnings in the Forge though, the fact it isn't OS supported does not mean you can't safely use the component. However, you can easily look at the source code of that component, and just use the RegEx.

You could also easily create your own with a Client Action with a JavaScript Statement:

var regExp = new RegExp($parameters.RegEx, $parameters.Options);
var result = $parameters.Input.match(regExp);
if (result !== null) {
    $parameters.Result = result[0];
    $parameters.IsMatch = true;
}


Thank You so much Kilian...

You're most welcome Melody :). Could you please mark my answer as Solution, in case it solved your problem? Thanks!

Kilian Hekhuis wrote:

You're most welcome Melody :). Could you please mark my answer as Solution, in case it solved your problem? Thanks!

Hi can you please give more clear suggestion on the below java script.

var regExp = new RegExp($parameters.RegEx(Do we need to pass pattern like [@#$%!,..?] ), $parameters.Options(what should be passed here);
var result = $parameters.Input.match(regExp);
if (result !== null) {
    $parameters.Result = result[0];
    $parameters.IsMatch = true;
}


Hi Melody,

This is standard JavaScript, so the parameters should be what JavaScript expects. However, find attached an eSpace with a RegExSearch Client Action for your reference.

Kilian Hekhuis wrote:

Hi Melody,

This is standard JavaScript, so the parameters should be what JavaScript expects. However, find attached an eSpace with a RegExSearch Client Action for your reference

Appreciate your help.Still i have a clarification

I am looking for the solution in mobile perspective and support both online and offline scenario.

Attached oml file I have used decimal condition input and pattern which I used to test my application using as you shared script. every time I am getting true even it is wrong patter.Kindly help on this resolve the issue.

Input value: 342434242423423424243.23423423423423

Pattern : “^\d{0,15}(\.\d{1,3})?$” (while run the application by default append “/^\d{0,15}(\.\d{1,3})?$/”)

Solution

Hi Melody,

Not sure what you're doing wrong (no time to check in detail), but I've created a small test program, and it works fine (i.e. with the patten you supplied and the input it returns False as expected). See attachment.

Solution

Kilian Hekhuis wrote:

Hi Melody,

Not sure what you're doing wrong (no time to check in detail), but I've created a small test program, and it works fine (i.e. with the patten you supplied and the input it returns False as expected). See attachment.


Thanks working:) :)

Good to hear! Happy coding :).