In my Jira automation, I have created a variable:
varReleaseVersion, which has a value 28.5
Then Im creating another variable:
FilteredReleaseVersions, with a value
{{#project.versions}}{{#name.startsWith(varReleaseVersion)}}{{name}},{{/}}{{/project.versions}}
With this definition FilteredReleaseVersions does not return anything.
When I change
FilteredReleaseVersions, with a value
{{#project.versions}}{{#name.startsWith("28.5")}}{{name}},{{/}}{{/project.versions}}
Then it returns correct results:
I have tried also
FilteredReleaseVersions, with a value
{{#project.versions}}{{#name.startsWith({{varReleaseVersion}})}}{{name}},{{/}}{{/project.versions}}
but then I get an error:
Hi @Anna Mjau -- Welcome to the Atlassian Community!
You are observing a long-standing limitation for rules, preventing filtering of the list because the first variable is not visible:
Once inside of a long-format iterator, only data from the iterator scope, and lower, is accessible.
For your scenario, you seem to only want the version name attribute. Thus, a workaround is to use a dynamic regular expression and the inline-format for iteration.
This will produce a list of values. If you are only expecting one (or no) results, please add the first function to the end.
When you need more attributes than just the name, an advanced version of this technique is required. To learn more about that, please read this article I wrote on it: Dynamic searches within a list.
Kind regards,
Bill
Heyo!
Assuming the variable is not empty where you try to access it (please check - it might be if it gets filled in a branch): You could try converting whatever type the variable has to string and see if that changes anything (low chances but perhaps worth a try):
{{varReleaseVersion.asJsonString}}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
That unfortunately did not work. It threw the same error:
Error rendering smart-values when executing this rule:
Parameters not closed: ({{varReleaseVersion.asJsonString: {{#project.versions}}{{#name.startsWith({{varReleaseVersion.asJsonString}})}}{{name}},{{/}}{{/project.versions}}
Regarding varReleaseVersion having value - it definitely has the value, because it is set right before the failing variable. And in later logs {{varReleaseVersion}} has the value. It just does not seem to work inside the .startsWith of the other smart value.
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.