Hello guys,
I am trying to set up some validation on one of my custom fields "User's Email Address" (customfield_10041) to make sure when a value is entered into that field, the email is valid or at least follow xxxx@yahoo.com format. Any suggestions on how this can be accomplished? All the articles I find are related to adding the scriptrunner plugin.
Just thought I'd share this as a handy REGEX rule.
^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$
I am currently using it on a Jira Service Management form (even though JSM has an out of the box "email" data type, the validation is broken. You can enter junk at the start (including spaces) and Jira doesn't catch it as invalid input hence falling back on this REGEX rule (it is common for people to paste the email out of their outlook contacts and include the junk text at the start).
A little explanation of the regex rule (and it should work for both of your cases).
Hope this helps you.
Just complementing with information, you can use a REGEX validator, but this can restrict the way this is done a little bit.
See how:
- In the transition of the flow where you want to include this validation, click on "Validator";
- Add the "Regular Expression Check" validator;
- Define the field that should receive the function;
- Configure the REGEX function as follows:
REGEX FUNCTION: [a-z]*[@][a-z]*[.][a-z]*
This will allow the field to have the following content:
fernando@yahoo.com
Or an email composed obeying exactly the following format:
fernandojira@yahoo.com
If the emails have the content ".com.br" at the end, the REGEX function must be adjusted.
Anything other than the two email examples I gave you won't work because they need to be exact according to REGEX.
The only thing you can change is "yahoo" to "gmail" or "outlook" for example
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hello!! this seems to be working great! I do have one question though, how can the regex be tweaked to include emails like @CO.state.us? These might get entered in commonly and I don't want to prevent users from submitting issues. Also, is there any way I can change the validation message? This is what I'm getting now:
Field User's Email Address with actual value 'test@myco.state.us' does not match regular expression [a-z]*[@][a-z]*[.][a-z]*
I would like to make it something simple, if possible.
Thanks for all your help!!!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Here is the REGEX function that will make the email work in the following format:
test@myco.state.us
REGEX: [az]*[@][az]*[.][az][.][az]*
Description:
[az]* = test
[@] = @
[az]* = myco
[.] = .
[az]* = state
[.] = .
[az]* = us
As I told you, REGEX is something that will only accept something within that very specific function. If you have email content that doesn't follow eg the REGEX rule, this won't work.
But for emails in this format: test@myco.state.us
This REGEX: [az]*[@][az]*[.][az][.][az]*
It will work perfectly.
About the validation message, we were unable to change it when using a REGEX function.
That's because it's a specific validation message that instructs the user in the REGEX function for the estimated field.
I understand that if we could put a display example, it would be interesting. What you can do is include a caption/description in the custom field, indicating the accepted email format.
Regards,
Fernando
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
so basically there is no way I can have a validator for both regular email addresses like xxx@yahoo.com and test@myco.state.us. The regex you just provided will only work for
test@myco.state.us, xxx@yahoo.com does not work now :(
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Exactly, Jay!
It may be possible to add more than one condition of this type using some app, like "Jira Misc Workflow Extensions".
It's a great app for automations and flow rules in general, but it has costs.
Natively, using the REGEX that I gave you, you will be able to validate only one email template and not two.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Out of the box (without add-on), it is very hard to validate on what users key in against a custom field (single line of text). The question to you is what are you trying to achieve if the entered value fails validation? (i.e. Stop issue being created or transitioned into next WF status etc)
Please advise, so there may be something that you can use (but it is not going to be perfect solution) based on your updated information which I can suggest.
Best, Joseph Chung Yin
Jira/JSM Functional Lead, Global Infrastructure Applications Team
Viasat Inc.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.