Screen action

  

I am trying to write a screen action that will test a zip code against the string

ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmonpqrstuvwxzy0123456789- 

with a space on the end. The idea is that I want to verify that there isn't special characters other than a - or a space included. The Zip codes I will be testing include Canada so I need to check the Alphabet as well as the numbers from 0-9. I want to return a clean zip code that only allows what is in my test string. When I run it, any zip code I enter just loops, and nothing is cleaned up and it still is able to be saved to the database with errors. My guess is that I don't have enough input parameters set up or they are assigned the wrong values to actually may this run correctly. I am very thankful for any help that you may be able to provide.

Why don't you use a regular expression and validate it against the UPPER(zipcode)?

You can use the following Regular Expression: ^[A-Z0-9 \-]+$

Explanation of the regular expression:

^: Begin of string

A-Z: Any character from A to Z

0-9: Any digit between 0 and 9

" ": A space

-: a dash

[...]+: 1 or more of any of the characters between the brackets.

$: End of string


Kind regards,

Remco

Yeah, I agree with Remco, a regular expression is most of the time the best way (no really, you don't have two problems then). What Remco failed to mention is where you can find it on the OutSystems Platform: it's in the Text extension, action Regex_Search.

set the following parameters of regex_search as:

Text  [your input field variable name]

Pattern  "^[A-Z0-9 \-]+$"


then use the conditional if widget and set it  as Regex_Search.Found 


and that's it.