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?
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
@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
Rule
Create New Issue Specifics
Newly created Issue
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hmmm...I just tried that in a rule and it worked as expected (for Jira Cloud). That may indicate:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Bingo! The problem was that the Version name wasn't the same in both.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You used wrong brackets. Versions should be array.
Please check this question on stackoverflow
Regards,
Seba
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.