Workflow validators : Regular Expression Check - Fields Applicable

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

This widget could not be displayed.

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.

This widget could not be displayed.

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.

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)

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.

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.

This widget could not be displayed.

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?

 

This widget could not be displayed.

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
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted Wednesday in New to Jira

Are you planning to trial, or are currently trialling Jira Software? - We want to talk to you!

Hello! I'm Rayen, a product manager at Atlassian. My team and I are working hard to improve the trial experience for Jira Software Cloud. We are interested in   talking to 20 people planning t...

115 views 2 0
Join discussion

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you