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

How to add multiple "affected services" via automation

Charlie Misonne
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 24, 2022

Via an automation rule I have a field called Application. This is a custom Insight field.

For each selected value in this application field I need to set an Affected services (= default field with services from OpsGenie)

Unfortunately the affected services field does only support the set operation and not add meaning all values have to be provided at once.

This works:

{
"update": {
"Affected services" :
[{"set":
[{"id":"{{lookupObjects.first.Service.Service ID}}"}]
}]
}
}

This doesn't:

{
"update": {
"Affected services" :
[{"add":
[{"id":"{{lookupObjects.first.Service.Service ID}}"}]
}]
}
}

Does anyone have creative ideas to solve this?

Snippet of my rule: 

2022-05-24 09_10_51-Automation - Jira.png

2 answers

1 accepted

1 vote
Answer accepted
Marius Stauga June 10, 2022

Hi Charlie, 

I had the same issue, please look at the next page. Loop-over list option in a combination with advanced branching worked for me.

Goodluck

Marius

Charlie Misonne
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
June 10, 2022

Hi Marius,

Thanks for replying on this question. In the meantime I already found a solution but it is very similar to the post you linked.

I am looping over my list of values in the "edit issue task":

{
"update": {
"Affected services" :
[{"set":[
{{#lookupObjects}}
{"id":"{{Service.Service ID}}"}
{{^last}}, {{/}}
{{/}}
]
}]
}
}

I'll mark your answer as accepted to close this :-)

Renatão November 21, 2023

I used the same solution above, but only one "Servico" is added to Affected services. It seems that the command is overriding the other items. Any thoughts?

image.pngimage.png

Renatão November 21, 2023

In my case, I have three different services to be added. The logs show that the branch rules work for the three services perfectly, but only one of them is added to the list (that was previously empty - before the automation).

0 votes
Eric
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
May 26, 2022

Hi @Charlie Misonne 

 

Can you try changing your second JSON snippet so the value of "add" is an object? At the moment, the value of "add" is an array.

 

I'm just trying to follow the example outlined in https://support.atlassian.com/cloud-automation/docs/advanced-field-editing-using-json/.

 

Eric

Charlie Misonne
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 27, 2022

Hi Eric,

Thanks for your suggestion.

I actually got an error along the lines of: add operation is not supported.

I also double checked using the /editmeta endpoint and here is the result:

https://<xxx>.atlassian.net/rest/api/3/issue/TSD-530/editmeta

"customfield_10036": {

    "required": false,

    "schema": {

        "type": "array",

        "items": "service-entity-field",

        "custom": "com.atlassian.jira.plugins.service-entity:service-entity-field-cftype",

        "customId": 10036

    },

    "name": "Affected services",

    "key": "customfield_10036",

    "autoCompleteUrl": "https://<xxx>.atlassian.net/rest/service-registry-api/service?query=",

    "operations": [

        "set"

    ]

}

Suggest an answer

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

Atlassian Community Events