Hello,
I created a web automation in Jira where I want it to send me a json with the fixVersions list. It should only contain the id and the released flag. I came up with the following solution. Is there a better solution where I don't have to loop and deal with json formatting?
```
{
"issue_id": "{{issue.id}}",
"issue_key": "{{issue.key}}",
"fixVersions": [
{{#issue.fixVersions}}
{
"id": {{id}},
"released": {{released}}
}{{^last}},{{/}}
{{/}}
]
}
```
or by filtering only the not-released ones
```
{
"issue_id": "{{issue.id}}",
"issue_key": "{{issue.key}}",
"fixVersions": [
{{#issue.fixVersions}}
{{#if(not(released))}}
{
"id": {{id}}
}{{^last}},{{/}}
{{/}}
{{/}}
]
}
```
Thanks
Yusuf
Hi @Yusuf Kör ,
this looks about right to me.
I would hide away some of the complexity in a variable. Let's say you create {{releasedVersionIds}} - which you set equal to:
[ {{#issue.fixVersions}} {{#IF(not(released))}}{{id}}{{^last}}, {{/}}{{/}}{{/}} ]
This way you can easily set up your request data like this:
{
"issue_id": "{{issue.id}}",
"issue_key": "{{issue.key}}",
"fixVersions": {{releasedVersionIds}}
}
More concise and easier to read/understand.
Alternatively and depending on the runtime receiving the data you could just send the info in separate arrays like {{issue.fixVersions.id.asJsonArray}} and {{issue.fixVersions.released.asJsonArray}} and zip them in you receiving runtime. That would look like;
{
"issue_id": "{{issue.id}}",
"issue_key": "{{issue.key}}",
"fixVersionIds": {{issue.fixVersions.id.asJsonArray}},
"fixVersionReleaseState": {{issue.fixVersions.released.asJsonArray}}
}
Hope this helped. What's your thought on this?
Greetings
Gideon
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.