Appian Community
Site
Search
Sign In/Register
Site
Search
User
DISCUSS
LEARN
SUCCESS
SUPPORT
Documentation
AppMarket
More
Cancel
I'm looking for ...
State
Not Answered
Replies
6 replies
Subscribers
8 subscribers
Views
2273 views
Users
0 members are here
Share
More
Cancel
Related Discussions
Home
»
Discussions
»
AI and Rules
Hi, my users have to enter a 10 digit barcode number. I want to do some bas
moritzw
over 10 years ago
Hi,
my users have to enter a 10 digit barcode number. I want to do some basic validations on the field:
if(len(tointeger(ri!barcodeNumberValue_txt))<>10,"Error Msg.",""),
if(len(tointeger(ri!barcodeNumberValue_txt))<>len(ri!barcodeNumberValue_txt),"Error Msg.","")
The first one works fine, but the latter one doesn't work for large numbers. Any ideas how could validate that the field only contains digits?
TIA, Moritz
OriginalPostID-139230
OriginalPostID-139230
Discussion posts and replies are publicly visible
0
PhilB
A Score Level 1
over 10 years ago
Have you considered using regular expressions? There's a plugin that allows this:
forum.appian.com/.../summary
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Tim
Certified Lead Developer
over 10 years ago
The regex expressions are very useful in multiple scenarios. Using the plugin Phil suggest you could use the following:
regexmatch("[A-Z]", ri!barcodeNumberValue_txt)
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
PhilB
A Score Level 1
over 10 years ago
You may find this tool helpful:
http://www.regexr.com/
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
best
Certified Lead Developer
over 10 years ago
tointeger("987653214032") will give you infinite, if the number has more than 10 digit.
So, try this:-
if(len(cleanwith(ri!barcodeNumberValue_txt,"0123456789"))<>10,"Error Msg.","")
if(len(cleanwith(ri!barcodeNumberValue_txt,"0123456789"))<>len(ri!barcodeNumberValue_txt),"Error Msg.","")
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
moritzw
over 10 years ago
Thanks for all the quick responses!
The cleanwith approach is a great idea. I will keep the regex in mind though if there are more complex validation requirements in the future. Thanks!
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Conor Cahill
Certified Lead Developer
over 10 years ago
You'll also want to be careful doing an len() after tointeger(). Leading 0's will be taken off and not counted for the length (e.g. len(tointeger("001")) returns 1). Assuming you go with the cleanwith() approach you won't be using the tointeger() so you won't need to worry about this, but it's something to keep in mind.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel