It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Workflow validators : Regular Expression Check - Fields Applicable

John Bayne Aug 26, 2014

I'm evaluating on Jira 6.2.7 sp don't know if this applies to the latest Jira, can anyone advise?

On trying to add a Regular Expression Check validator to a state transition the set of fileds available is just: Business Value, Description, Epic Color, Epic Name, External Issue ID, External Issue URL, <a local custom field>, <a local custom field>, Status Whiteboard, Story Points, Summary, <a local custom field>

What controls a field's inclusion in this set?

4 answers

1 accepted

0 votes
Answer accepted
John Bayne Aug 27, 2014

Thanks for the advice, most appreciated.

I've a lot to do on Jira I suspect but will take a look at using the script_runner in due course, if my Project Managers, want the extra control in place. However, I suspect it will not be a big issue for them anyhow.

1 vote
Nic Brough [Adaptavist] Community Leader Aug 26, 2014

The field must contain a text based field.

Not dates, numbers or options (select lists and their variants), it's got to be text based. There's no point in reg-exing non-text fields, their values are controlled and validated already, a user can't get them worng.

John Bayne Aug 27, 2014

Thanks, you know that feeling just after you hit 'submit', when you go d'oh!? :-)

However, what drew me into that question was wondering if I could do something like: Make a field mandatory at a transition based on the contents of another field?

E.g. If 'Resolution' has been set to 'Fixed' then make some other field mandatory.

I guess this form of combinational logic isn't supported?

(Additionally as I'd want to do this within the Resolve transition screen, it would rely on the value as cached in the browser as opposed to that in the database)

Nic Brough [Adaptavist] Community Leader Aug 27, 2014

Yup, I do that at least once a day!

Validators are a bit limited in Jira when you first look at them, but there's a good reason - the combinational logic you're talking about is the sort of thing you can't code a generic approach to. Every installation, every requirement, every transition could need something different, so it's really quite difficult to do.

You can use more than one validator in an "and" pattern ("field X must be filled" and "field Y must be > 7" type things), but for more complex stuff, including providing different validators, you need code.

Personally, I use the script runner for validators because you can build what the heck you want without having to write a whole plugin to do it. "If resolution == fixed and customfield_12345 == "" then return false" is almost a one-liner in the script runner.

As for your thought about the browser/database, this is something that most people don't think about, and hence sometimes they get very confused. It's nice to see someone thinking it through properly for a change! The trick here is understanding the timing cycle - a validator executes between the user clicking "do it" and Jira going "oi, database, here's an update". At that point, it has two sets of data for the issue - the current stored data AND what the user has entered. It's not the value "cached in the browser", it's the value that the browser has posted to Jira, so one step further, but the validator has full access to both versions of the data, and the whole point of the validator is to block the "oi, database" call if the user's entry is not good enough. So, yes, your code has access to what the user entered. And the current Jira values.

Paul M Sorauer Aug 02, 2018

Sure, I understand your point that "There's no point in reg-exing non-text fields, their values are controlled and validated already, a user can't get them worng." but what if the option selected is not valid for that particular transition?

For instance, when 'closing' a task as it's no longer needed, the resolution can be many things such as "Won't Do" or "Duplicate" but in this context "Done" is not a logically valid choice. I hate the fact that some simple things just aren't possible to check and don't want to have to purchase an addin for a single requirement as we have 100's of users.

There should be a simple validator to check the value of a field such as an Options field.

0 votes
Daniel Luevano May 05, 2015

Hi I need to add the next regex pattern to check versions:

/^\d{1}\.\d{1,2}\.\d{1,2}\.\d{1,4}\-\S/ - I wrote it in Javascript, but the validation says that it need Java syntaxis. I was researching about it and they said duplicate the '/' but it didn't work, any advice?


0 votes
muhammetayal Oct 09, 2017

Hi All, 

I need to a regex format for below sentence :) 

I want to write a script and  it should take after  the "Muhammet Ayal Test" words. Don't take ABCD-1243

ABCD-1243: Muhammet Ayal Test

What is the regex codes :) 

Thanks for now

Suggest an answer

Log in or Sign up to answer
This widget could not be displayed.
This widget could not be displayed.
Community showcase
Published in Next-gen

Introducing subtasks for breaking down work in next-gen projects

Teams break work down in order to help simplify complex tasks. This is often done iteratively, with tasks being broken down into smaller tasks and so on until the work is accurately captured in well-...

1,095 views 13 15
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you