Automate population of Affects Version field

Nicole Baratta
Contributor
November 18, 2021

I'm setting up an automation that is creating a new issue in a different Jira project and I can't seem to get the Affects Version field to carry over. I tried doing it with the 'Choose fields to set from' pull down, but the ID for the version is different in both projects even though the name is the same.  So I tried to do it in the 'More options' with :

{
"fields": {
"versions" : { "name": "{{versions.name}}"}
}
}

But it's not working either.  If I put 

Affects Version: {{versions.name}}

In the Description field, the right thing does show.  Am I doing something wrong in the 'More Options' section? 

2 answers

1 accepted

0 votes
Answer accepted
Bill Sheboy
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.
November 19, 2021

Hi @Nicole Baratta 

Without seeing your rule details...It seems you are trying to copy that field from one project to another, and the number of values to use in the JSON is unknown.  Correct?

If so, you would need to build the expression using list functions and then place that in the JSON.

You have already identified the correct smart values and syntax for Affects Version.  Let's assume your source is the {{triggerIssue}} for the rule.  The JSON would be something like this:

{
"fields": {
"versions" : [
{{#triggerIssue.versions}} { "name" : "{{name}}" } {{^last}}, {{/}} {{/}}
]
}
}

If that doesn't work because of the nested brackets, consider building the expression from the list as a created variable, writing it to the audit log to confirm it, and then inserting that variable into the JSON.

Kind regards,
Bill

Nicole Baratta
Contributor
November 19, 2021

@Bill Sheboy Thank you so much! You did assume correctly, but this didn't seem to work.  I'm including my entire rule here. It did run successfully, but the Affected Version is not coming over into the new issue. 


Trigger Issue

Screen Shot 2021-11-19 at 11.31.54 AM.png

Rule

Screen Shot 2021-11-19 at 11.30.29 AM.png

Create New Issue Specifics

Screen Shot 2021-11-19 at 11.31.18 AM.png

Newly created Issue

Screen Shot 2021-11-19 at 11.32.23 AM.png

Bill Sheboy
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.
November 19, 2021

Hmmm...I just tried that in a rule and it worked as expected (for Jira Cloud).  That may indicate:

  1. The specific Affects Version name from the source issue does not *exactly* exist in the destination project.  Please confirm that by comparing the source issue project with the destination setup.  Remember to check for any spacing differences between the names.
  2. The Affects Version is not an editable field for your target issue type.  Please check with your site admin if Affects Version is on the view.
  3. Or, there is something incorrect setting that custom field in the JSON before setting Affects Version.  To confirm that, try remove the set for customfield_12311240 from the JSON and see what happens.
Nicole Baratta
Contributor
November 19, 2021

Bingo! The problem was that the Version name wasn't the same in both.

Like Bill Sheboy likes this
0 votes
Sebastian Krzewiński
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 18, 2021

Hi @Nicole Baratta 

 

You used wrong brackets. Versions should be array.

Please check this question on stackoverflow

 

Regards,

Seba

Nicole Baratta
Contributor
November 19, 2021

Thanks, @Sebastian Krzewiński ! I read through that but I'm not sure of the syntax to use if I don't know what the versions are or how many of them there are.  When I look at that thread they're using known values.

Suggest an answer

Log in or Sign up to answer