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

How to retrieve affected version via script runner?

xion_admin February 25, 2016

During creation of a bug issue, I need a validator to check whether the affected version field is empty or not?

So I want to prevent the creation of the issue, when no affected version was inserted.

 

How can I do this with script runner?

 

3 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

1 vote
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.
February 25, 2016

Hi JIRA Admin,

This requirement can be achieved using a simple Scripted Validator placed on the create transition which uses the code and configuration shown below.

Code:

issue.getAffectedVersions().size() >=1

Configuration:

image2016-2-25 14:42:39.png

Example output:

image2016-2-25 14:43:8.png

I hope this helps.

Thanks

Kristian

xion_admin February 25, 2016

This works, however, is there a way to mark the field with a little asterisk?

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.
February 25, 2016

Hi,

In order to show the asterisk you would need to mark the field as required in the field configuration scheme like Nic suggested below.

Thanks

Kristian

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.
February 25, 2016

Hi JIRA Admin,

If this answer was useful can you please mark it as accepted so it is easy to find for other users with a similar question.

Many Thanks

Kristian

4 votes
Mohamad Khalife
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.
February 25, 2016

Use this:

import com.atlassian.jira.issue.Issue
import com.opensymphony.workflow.InvalidInputException
Issue myIssue = issue

    if (! myIssue.getAffectedVersions().size()) {
        invalidInputException = new InvalidInputException("versions", "Affects Version/s is required in this context.")    
    
}
xion_admin February 25, 2016

This doesnt work for me. I could create the issue.

I also get an error message from script runnter: "the variable invalidInputException is undeclared"

0 votes
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.
February 25, 2016

Or just make it mandatory in the field ocnfiguration

xion_admin February 25, 2016

I tried this first, but for unknown reason it didn't worked for me.

I just marked the field as required. Should I need to enable something else too?

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.
February 25, 2016

Nope.  If you have marked it required in the field configuration correctly (I usually manage to do it in the wrong field configuration), then you'll get the mandatory star next to the field on create and won't be able to complete without selecting a version.

TAGS
AUG Leaders

Atlassian Community Events