[jjupin] How to loop through version specific issues?

Lucas Molenaar
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 19, 2014

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

2 votes
Answer accepted
Alexandru_Iacob
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 19, 2014

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;
}

Lucas Molenaar
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 20, 2014

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"
Alexandru_Iacob
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 20, 2014

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";

Lucas Molenaar
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 20, 2014

Thanks you so much!

Lucas Molenaar
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 20, 2014

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"

Alexandru_Iacob
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 20, 2014

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.

Lucas Molenaar
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 20, 2014

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

Suggest an answer

Log in or Sign up to answer