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

Antonio Duarte August 11, 2014

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

1 vote
Answer accepted
JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 18, 2014

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
Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 11, 2014

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.

Antonio Duarte August 11, 2014

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.

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 12, 2014

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.

Antonio Duarte August 12, 2014

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.

Antonio Duarte August 18, 2014

Hi, Nic,

Did you read my last post dated Aug, 12?

Thanks.

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 18, 2014

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()

0 votes
Antonio Duarte August 12, 2014

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