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,461,051
Community Members
 
Community Events
176
Community Groups

How to populate a JSON structure with task & subtask fields

Hello!

I'm doing an automation that will call a REST endpoint with a JSON structure containing a 'header' with info from the task and one 'line' per subtask with info from the subtask.

Output should be something like this:

{
    "YTXTCAB": "{{issue.summary}}",
    "YWSCYLINSOL":
    [
        {
            "$uuid": "{{issue.subtasks.uuid}}",
            "YITMREF": "{{issue.subtasks.YITMREF}}",
            "YITMDES": "{{issue.subtasks.YITMDES}}",
            "YQTYPUU": "{{issue.subtasks.YQTYPUU}}",
            "YEXTRCPDAT": "{{issue.subtasks.YEXTRCPDATv}}",
            "YCCE3": "{{issue.subtasks.YCCE - Proyecto}}",
            "YTXTLIN": "{{issue.subtasks.descripcion}}"
        },
    ]

}

 

Where the inner structure is replicated for each subtask inside the array [].


The above example lines do not work, of course, as you get just one line in the array with an all the field values from all subtasks in each field. Like below:

 

{

  "YTXTCAB": "TEST - Sage",

  "YWSCYLINSOL":

  [

     {

       "$uuid": "123-abc, 456-def",

       "YITMREF": "YITMREF 1, YITMREF 2",

       "YITMDES": "YITMDES 2, YITMDES 2",

       "YQTYPUU": "1.0, 2.0",

       "YEXTRCPDAT": "2022-02-17, 2022-02-18",

       "YCCE3": "YCCE 1, YCCE 2",

       "YTXTLIN": ""

     },

  ]

}

 

How would you go about getting one line of the inner structure into the JSON for each subtask?

 

Thanks

Jorgen

1 answer

1 accepted

0 votes
Answer accepted

I have found the solution, pasting it below:

{
    "YTXTCAB": "{{issue.summary}}",
    "YWSCYLINSOL":
    [
       {{#issue.subtasks}}
       {
          "$uuid": "{{uuid}}",
          "YITMREF": "{{YITMREF - Código artículo}}",
          "YITMDES": "{{YITMDES}}",
          "YQTYPUU": "{{YQTYPUU - Cantidad a comprar}}",
          "YEXTRCPDAT": "{{YEXTRCPDAT - Fecha recepción prev}}",
          "YCCE3": "{{YCCE - Proyecto}}",
          "YTXTLIN": "{{description}}"
       }
       {{^last}},{{/}}
       {{/}}
    ]
}

Suggest an answer

Log in or Sign up to answer
TAGS

Atlassian Community Events