Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,462,647
Community Members
 
Community Events
176
Community Groups

How do you reference Fix versions - Next unreleased version in custom JSON?

I want to set my rule to add the Next unreleased version instead of setting it to the Next unreleased version but I dont know what the field name is called. This is what I'm envisioning:

{
"update": {
"fixVersions": [
{
"add": {
"name": fixversions.nextUnreleasedVersion
}
}
]
}
}
Is this possible? I've been looking for a way to see the corresponding json to my current rule action but I haven't found it.Screen Shot 2021-12-16 at 1.39.28 PM.png
Thanks for your help,
Lynne

 

1 answer

1 accepted

1 vote
Answer accepted

Hi @Lynne Robinson 

If I understand your use case, you want to add the Next Unreleased Version to fixVersion in addition to any current values in fixVersion.  Is that correct?  If so...

Short version: you cannot do that without a work-around

Longer version:

JQL knows about Next Unreleased Version for queries, and rules know about that value for field edits, but the issue fields know nothing about other versions/releases: only their current values.

One work-around would be:

  • save the current value of fixVersion in a created variable
  • use edit to set the value of fixVersion to the Next unreleased version
  • use the re-fetch action to reload the trigger issue
  • and now edit the issue again, adding the saved values from the created variable using the JSON edit format

Kind regard,
Bill

Thank you @Bill Sheboy for the workaround! Your steps worked perfectly and my fixVersions are now exactly what I needed. Appreciate the help!

Like Bill Sheboy likes this

Awesome! I am glad to learn that helped, Lynne.

I know it's an old post, but how did you add the saved values with the JSON format?

I'm trying things like

{

  "update": {

    "fixVersions": {{origVersions.name.asJsonObjectArray("name")}}

   }

}

 

which is not correct because it's missing the "add" verb. how can this be done?

Hi @Amy Chan 

Please take a look at this documentation for examples of add versus update with JSON, and of how to modify the fixVersion field: https://support.atlassian.com/cloud-automation/docs/advanced-field-editing-using-json/

Kind regards,
Bill

Hi @Bill Sheboy - have done, still not sure. Update has to be used with a list of set/add/remove directives, of which I want add. To add fix versions you seem to have to add them one by one a la

"update": {

    "fixVersions": [

        { "add": {"name": "versionName1"}},

        { "add": {"name": "versionName2"}},

        { "add": {"name": "versionName3"}}

    ]

}

 

and so on (there is the example for labels showing how to add an array of labels to the set of labels).

But `origVersions.asJsonObjectArray("name")` will produce an array of `{"name": "versionName_i"}`, but now I need to nest it further in an "add".

 

Using `"fixVersion": {{origVersions.asJsonObjectArray("name").asJsonObjectArray("add")}}` would seem to do what I want, except this just gives me "invalid JSON" with no way to view the generated JSON to see what's gone wrong.

 

Do you have an example of how precisely to do that last step?

Hi @Amy Chan  - The only way I could make it work was to save each element in the array separately (screenshot below) and then I use an update similar to the one you have.

Screen Shot 2022-07-03 at 11.31.35 AM.png

It became quite long because this forced me to check the number of fix versions that already exist on the issue first and then I followed @Bill Sheboy 's steps for each if/else block. So i ended up checking 4 cases: no fix version, 1 fix version, 2 fix versions, and 3 fix versions. I figured that would be a maximum number of fix versions for our project.

Hope that helps!

Like Bill Sheboy likes this

@Lynne Robinson ahh, thanks. Here is what I ended up with (and was hoping to simplify) - may be a little easier than yours. The idea is to save the original version(s), set the fix version to latest unreleased, save that too, change the issue back to the original version(s) and finally append the latest unreleased using the JSON (since this is just a single version).

1. create variable origVersions = issue's fix versions

2. edit the issue to set fixVersion = latest unreleased

3. re-fetch issue data

4. create variable latestUnreleasedVersionName = {{issue.fixVersions.first.name}} (we know it's only one version long) - basically store the name of the 'latest unreleased'

5. edit the issue to set fixVersion back to {{origVersions}} (not using the JSON - just using the normal 'edit issue') 

6. use the JSON format to append the latestUnreleasedVersionName back to the versions list 

 

still very verbose but saves the 4 cases and adding one by one.

Like Bill Sheboy likes this

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
PERMISSIONS LEVEL
Site Admin
TAGS

Atlassian Community Events