[jjupin] How to loop through version specific issues?

I want to perform an action/change to all issues referenced in a specific version.

e.g. during a 'SIL Post-function Function' I want to set the value for a hidden custom field to a specific value, for all issues references in the version selected in a 'version-picker custom field'. For example, for all issues fixed in version "4.1.0.0" I like to set the value of the custom field "check" to "true".

Could someone please help me with the correct syntax?

1 answer

1 accepted

Hi Lucas,

This can be achieved using the selectIssues routine that accepts a jql as parameter:

string[] issues = selectIssues("fixVersion = 4.1.0.0");
for(string iss in issues) {
%iss%.check = true;
}

Hi Elexandru, thank you very much! I am amased by the power of this addon.

Some remaining questions :)

I now have (which is not working):

string[] BaselineVersion = Baseline;
string[] issues = selectIssues(BaselineVersion);
for(string iss in issues) {
%iss%.Locked = "Yes";
}
  • "Baseline" is the name of the "Version picker" custom field
  • "Locked" is the name of the "Text field" custom field
  1. The value of the text field "Locked" is not set to "Yes". Could you explain what I do wrong?
  2. Could you provide an example of manipulating a 'Select List (single choice)' or a 'Radio Button' field, both have two values "Yes" and "No"

1. For the selectIssues routine you have to provide a jql as parameter (eg "Baseline = 4.1.0"). You forgot the "Baseline = " part. Notice also that the Baseline value must pe cast to string before using it in the jql. Just store it in a string variable and use that instead:

string BaselineVersion = Baseline;
string[] issues = selectIssues("Baseline = " + BaselineVersion);
for(string iss in issues) {
%iss%.Locked = "Yes";
}

2. Setting the value for a Select List or a Radio Button field isn't different from setting a value to a text field:

%iss%.SelectList = "Yes";

%iss%.Radio = "Yes";

Thanks you so much!

Could you please have another look at the code snippit, it is not working for me (Archiving works but changing the text value is not):

See screenshot below after pressing the "Lock Baseline" version. I hoped the value for the text field "Locked" was set to "Yes"

Try to put selectIssues("Baseline = '" + BaselineVersion + "'"). If the version name has more than one word, as in your case, it must be surrounded by quotes in the jql. Let me know if this solves your problem.

Works, you are a champ! Great tool and great support

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Julia Dillon
Posted Apr 17, 2018 in Jira

Tell us how your team runs on Jira!

Hey Atlassian Community! Today we are launching a bunch of customer stories about the amazing work teams, like Dropbox and Twilio, are doing with Jira. You can check out the stories here. The thi...

772 views 2 19
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