Video Screencast Help
Search Video Help Close Back
to help
New in the Rewards Catalog: Vouchers for "Symantec Technical Specialist" and "Symantec Certified Specialist" exams.

Validating an email address

Updated: 24 May 2010 | 5 comments
Jimbaland's picture
0 0 Votes
Login to vote
This issue has been solved. See solution.

Does anyone know of a component that will validate an email within a workflow? The problem I am running into now is that I have a field for the user to enter an email address to be CCd with updated ticket info. If the email address is invalid, I receive an application error but the process completes sending emails to the rest of the valid recipients. I guess I could create a blanket page for all errors telling the user to go back and check the email addresses entered, but that wouldn't solve the problem of the intended person not receiving the email. Thanks

discussion Filed Under:

Comments

reecardo's picture
20
Apr
2009
0 Votes 0
Login to vote

Google up some "regular

Google up some "regular expression" text for valid emails and make use of the "Find Pattern in String" component.

Hope this helps

ChrisBern's picture
20
Apr
2009
2 Votes +2
Login to vote

A few options

If you actually need to not only make sure that the email address is in the proper format, e.g. x@y.com, but that it is a valid email address as well, then you might want to use a webservice to validate the email address.  This is just one example that I found through a Google search:  http://www.webservicex.net/ValidateEmail.asmx.  You would, of course, use a webservice generator to connect to this webservice.  This particular one is nice, but seems pretty slow, so you may want to (a) increase the timeout on the webservice component that you generate so that your process doesn't time out, and/or (b) look for a similar webservice that is faster.  The result of this one, by the way, is a Logical True/False variable, so you could easily analyze the result with a True False Rule component.

If you don't necessarily need to know that it's a valid email address, but just want to make sure that it fits the x@y.com format, for example to avoid typos or misunderstandings of what is being asked for in a text field, then you can do that within your project itself without calling out to a webservice:

  1) Create your form which asks for an email address, e.g. from a TextBox component

  2) Double-click on the TextBox component to edit it.  On the Functionality tab, scroll down to the bottom and checkmark Use Custom Validation.  

  3) Click the elipsis next to Custom Validation Model.  This is your "error checking model" for the form.  Add a Find Common Pattern component to this submodel.  This component is a great way to see if a variable matches a common pattern, e.g. an email address, URL, credit card number, postal code, etc.  Your variable that you want to check against will be ThisFormData.WhateverYourEmailVariableIsNamed.  Checkmark Internet e-mail address as your "check".  OutputIndex isn't important for us here, so just put OutputIndex or something like that for the variable name.

  4) You will want two End components, one to indicate no error, and the other to indicate that there was an error (in our case, to indicate that the email address supplied on the form was not in correct email format).  So, copy and paste your End component so that you have two now.  Rename one something like "Error" and the other something like "No Error" (be more descriptive, though, so you'll remember what you did 6 months from now).

  5) In the No Error end component, double-click on it and set the CustomValidationResult mapping to Null.  This is telling the form that there is no (null) error message for this form.

  6) In the Error end component, double-click on it and set the CustomValidationResult mapping to CreateValue, and then in Description and Name, type something descriptive such as, "The email address given is not a valid email address".  This is, of course, the error message the user will see.

  7) Out of the Find Common Pattern component, connect the Internet Email Address path to the No Error end component, and connect the No Match to the Error end component. 

When you run this form, try typing in things that don't match the email format...you'll see that you can't get past the form until you give a properly formatted email address.  FYI I don't believe it matters whether you perform this validation on the TextBox component, or the OK button, or any other control on your form...the custom validation model will only get evaluated when the user is LEAVING the form, not when he or she is leaving a given control.

Write back if anything is unclear...it looks like a lot steps but is actually quite easy (and powerful) to add in this type of custom validation to a form.

Jimbaland's picture
21
Apr
2009
1 Vote +1
Login to vote

Sweet!!

For now this is just what I needed, and very simple to set up. You're also right that this is a VERY powerful method of validation and look forward to expanding upon it in the future. Now I'll try and tackle calling the webservice. Thanks again.

Jimbaland's picture
21
Apr
2009
0 Votes 0
Login to vote

CC fields are optional

So, the CC fields on my form are optional. When I run my project with the fields blank I get an application error because there was nothing for the validation rule to check. Any way to set this up to work only when there are characters in the field?

Jimbaland's picture
21
Apr
2009
1 Vote +1
Login to vote

Nevermind

Nevermind. I put a "text exists" component right before the "find common pattern" component. if there is text in the text box it goes on to "find common pattern", if not it goes to the "good email" end component. Workflow is fun!!