Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

How to validate that a linked issue has been entered on creating an issue?

Nick Hassell
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.
January 9, 2020

When a user (service desk agent) creates an issue, I have included the 'linked issues' field in the create screen.  I want to make sure that the user has entered at least one issue in this field.

I am running JIRA Cloud, and have Scriptrunner available.

I have tried making the field mandatory in the field configuration scheme, but I think this only enforces the link type.

I have tried to set a validator in the workflow - 'Field Required Validator' but there is no 'linked issues' field in the list of possible fields.

I have tried to write a 'Scriptrunner script validator' in the workflow.  I have used this expression: (issueLinkManager.getOutwardLinks(issue.id).length) ? true : false

... but this always returns false.

Can anyone help please?

 

1 answer

1 accepted

0 votes
Answer accepted
Kristian Walker (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.
January 9, 2020

Hi Nick,

Thank you for your question.

I can confirm that we have created the Knowledge Base article located here which explains how Script Validators work inside of ScriptRunner for Jira Cloud. 

You will see in the Knowledgebase articlle that it shows that validators are defined using the Jira Expression Framework as documented in the Atlassian API documentation page located here.

We can confirm that when viewing the Jira Expression Framework API documentation page linked above you can navigate to the Context variables section which shows what variables are provided by this framework that can be used to create the expression. 

If you then click on one of the variables it will show all the properties that can be called on the variable for the expression such as for the issue variable.

I can confirm when reviewing the properties available to the issue variable one of the properties as described in the API documentation is the links property which contain the issue links for the issue and this is the property that you should look to check in your validator. 

I hope this information helps.

Regards,

Kristian

Nick Hassell
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.
January 9, 2020

Thanks - I hadn't found that documentation anywhere - it makes sense now.  So here's what works:

(issue.links.length) ? true : false

Easy when you have the documentation!

Kristian Walker (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.
January 9, 2020

Hi Nick,

Thank you for confirming that you have resolved your issue.

I can also confirm that I have come up with an alternative way to validate than an issue has at least one linked issue which is shown here and wanted to share this with you as well as a reference.

Regards,

Kristian

Duje November 14, 2020

Hi @Kristian Walker (Adaptavist) ,

I can't seem to open the bitbucket URL, could you please post the snippet? I am trying to validate a specific issue link at creation, but it seems to be empty even when issue link is selected(I assume the issue is not created yet thus having no IssueLink object).

For everyone having the issue, workaround would be creating the issue and having post function on create that would transition the issue forward if the conditions are met(You would need additional status on beginning). :)

 

Regards,

Duje

Kristian Walker (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.
November 15, 2020

Hi Duje,

I have just tested the URL and can confirm it works as expected.

Unfortunately, I can not share the content of the snippet here and it can only be accessed using the URL linked above.

I can, however, confirm that you can view examples for validators in our documentation site here.

As for validating a specific issue type then I can confirm that this is possible and as mentioned above you will need to review the Jira Expression Framework and the issuelinktype property that it provides to see how to check against the name of a link type.

Regards,

Kristian

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events