Validation of Linked Issues field doesn't work on wokflows!

I set the validator "If a value for field Linked Issues is not provided during the transition, show the following error: This field is required. " in the Create Issue transition in one of my workflows, and if I do not put anything on the Linked Issues fields when creating the issue, instead of informing the error message, JIRA shows me the validation error "Error creating issue: An unknown exception occured executing Validator com.innovalog.jmwe.plugins.validators.FieldRequiredValidator@7f9933ca: root cause: java.lang.NullPointerException" .

Any clue?

3 answers

1 accepted

You will need ActionContext to get the web request. It's fragile though. See eg https://answers.atlassian.com/questions/139592/check-for-duplicates-link-in-groovy-transition-validation-script

1 vote

Yes, that's because the field is not really a field - it's an area for the user to enter text that will be converted to issue links, not actual data to be checked. I'm afraid the JMWE isn't quite clever enough to validate this "field" - you'll need to find/write something that looks directly at the actual issue links to do this.

Hi, Nic,

I just need to grant that there is at least one issue linked. As I do not know too much about scripting, could you, please, write down a single line script that checks if there is any entry linked (id doesn't matter wich one). I guess that some simple check if the number of linked issues is >= 1 will satisfy my needs. Thanks.

Well, it depends on what plugin you're using for scripting. But I've never done it myself, I wrote a field that counted links years ago, and then used a "number > x" validator on it.

I use the JIRA Misc Workflow Extensions. It allows me to write very simple scripts to use in validations. As an example, I have the single-line-script "issue.issueTypeObject.name == 'Epic'" in one of my workflows that allows me to go on with this workflow only if the Issue Type that started it is of type 'Epic'.

Using this as a 'tip', I would like to write another similar single-line-script that checks how many linked issues there are in the Linked Issues 'field'. As I don't know exactly wich variables to check, I do not know how to do this.

As an example, just let's imagine that the variable that holds this value is named "LinkedIssues.size". Then, if I have something similar to "issue.LinkedIssues.size >=1", this boolean result would fit my needs.

Do you know exactly wich is the variable that I should check to build the small script?

Thanks.

Hi, Nic,

Did you read my last post dated Aug, 12?

Thanks.

No, my emails on followed questions have stopped arriving, so I've no way to see if people follow up, other than guess.

From memory, you need an issuelinkmanager object, then you can go

issueLinkManager.getIssueLinks(<issue>).size()

I use the JIRA Misc Workflow Extensions. It allows me to write very simple scripts to use in validations. As an example, I have the single-line-script "issue.issueTypeObject.name == 'Epic'" in one of my workflows that allows me to go on with this workflow only if the Issue Type that started it is of type 'Epic'.

Using this as a 'tip', I would like to write another similar single-line-script that checks how many linked issues there are in the Linked Issues 'field'. As I don't know exactly wich variables to check, I do not know how to do this.

As an example, just let's imagine that the variable that holds this value is named "LinkedIssues.size". Then, if I have something similar to "issue.LinkedIssues.size >=1", this boolean result would fit my needs.

Do you know exactly wich is the variable that I should check to build the small script?

Thanks.

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Nov 27, 2018 in Portfolio for Jira

Introducing a new planning experience in Portfolio for Jira (Server/DC)

In the past, Portfolio for Jira required a high degree of detail–foresight that was unrealistic for many businesses to   have–in   order to produce a reliable long-term roadmap. We're tur...

2,874 views 19 22
Read article

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