cancel
Showing results for 
Search instead for 
Did you mean: 

Expression to validate that a keyword contains a certain element as part of the value

Deanne_Devine
Star Contributor
Star Contributor

That was an overly complicated way of asking if there is a way to verify if an email submitted on a form is valid.

Here is the situation:

We collect information on a shared form. The information collected includes an email keyword that is used in the workflow for notifications, both in system events and ad-hoc tasks. When the email address is not formatted as an email address should be (basically, no @) the action fails and everything stops without an easily discernible (to the end-user) explanation.  It does generate a bug report, but it would be really nice if there was an expression that would validate whether or not the keyword contains the @ before the system tries to send out the notification. Then we could just display a nice message and ask the end user to check the email address and the end user wouldn't have to call for help.

I hope this makes sense! 

Thanks!

4 ACCEPTED ANSWERS

Ram_Kumar_Pula2
Confirmed Champ
Confirmed Champ

Hi Devine,

You can use a script that checks if an email provided is valid or not at the unity form level. If you are looking for something that validates when the form is submitted using regular expressions you can use this.

212b1bfe509f41efa4b0a8afbfcb8bab

 

You can replace %Vvalue with the email KW(%K000) and execute it.

 

Thanks,

Ram.

View answer in original post

Ram_Kumar_Pula2
Confirmed Champ
Confirmed Champ

Hi Devine,

If you want to validate at form level

1) Create 2 fields in the hidden section one for copying the value entered in the email field and other to write the value from the script (Valid/Not Valid)

2) Using custom action copy the email field value to the created field and execute a script when field not empty and get the value valid/not valid from the script.

3) If the script returns Invalid make the field as  invalidate using a custom action and display a msg something like "Please input a valid email address" 

NOTE: This validates only if the email maintains the standards for email format but not if this email exists or not? 

 

Thanks,

Ram.

View answer in original post

Deanne_Devine
Star Contributor
Star Contributor

I like both of these answers for different reasons - I think I will be able to use them for a lot of things in the future. If I want to check both the symbol (sorry, when I try to type it now, it brings up your names) and a '.') can I do both in one script with an &. Sorry I don't know the scripting very well. 

View answer in original post

Ram_Kumar_Pula2
Confirmed Champ
Confirmed Champ

You can look for both the "@" and "." in the same expression in work flow and in the same Script

 

96e7edf48544457a97fa31deea6bf673

 

Thanks,

Ram

View answer in original post

8 REPLIES 8

Ram_Kumar_Pula2
Confirmed Champ
Confirmed Champ

You can look for both the "@" and "." in the same expression in work flow and in the same Script

 

96e7edf48544457a97fa31deea6bf673

 

Thanks,

Ram

@Doug Stoots This is well explained but I want to stop the unity form from being submitted if the email address field is wrong.  Is it possible to do that with a custom action (I tried with iif and match and it doesn't like it)?  If I put the above in a workflow step in the system work of the initial queue will it stop the form from being submitted?  

Thanks!

Deanne_Devine
Star Contributor
Star Contributor

This is so helpful! Thank  you so much! I am going to do the evaluation in workflow because I don't know enough (anything:)) about how to write Unity scripts yet. I am going to try to find the expression cheat sheet, which I hear is somewhere on this site - this is going to come in really handy.

Thanks again!!

Doug_Stoots1
Confirmed Champ
Confirmed Champ

Hi Deanne,

As an extra note, you may want to be careful with just evaluating the value for containing the "@" and "." characters, since a valid email address requires them to be in a correct order as well. For example:

d3968608112047e39b942b0f9aece17c

This is obviously not a valid email but would evaluate "True" and would still cause the error you are encountering.

 

Checking the value against a regular expression (regex) may be a better option since it allows you to ensure the address adheres to a valid email format. For example:

0f40ea6a8b10415ea47c22c96cb958d5

In addition to checking to ensure proper format, it will return "False" if there are invalid characters (such as spaces) found in the address. This is configured with the "Evaluate Expression" rule type in Workflow with the following expression (for easy copying):

 

IsMatch(%Vvalue;"^([a-zA-Z0-9_\-\.]+)@([a-zA-Z0-9_\-\.]+)\.([a-zA-Z]{2,5})$";true)

 

Let me know if you have any questions and hopefully this helps!

 

Thanks,

Doug