How to update the approver groups for the affected services when an affected service is removed from the ticket.

Platform Notice: Cloud - This article applies to Atlassian products on the cloud platform.

Summary

During the approval step of a ticket involving affected services, modifying the number of services does not update the corresponding approver groups. If a service is added to the list of affected service, the corresponding approver group is added in the approvers but if an affected service is removed, the corresponding approver group is not removed.           

Environment

Jira Service Management Cloud

Diagnosis

The approver group field values do not update when one or more affected service(s) are removed from the ticket.

steps-to-reproduce.mp4 


Please generate Basic Auth Credentials for REST API

Under the heading "Supply Basic Auth Headers" of this document, please follow the steps 1-3 and copy the final string in the "Authorization" header value for all 3 "Send Web Request" action.                                   

Solution

Description

The solution is based on the automation. The automation rule will monitor the affected services field for the deletion  of a service and then updates the Approver Groups accordingly.

Automation Rule Components Explained 


The Rules trigger is When field value changs (Affected Services) 


The next action sends a webhook to Jira to request data for the current issue. The objective is to get the affected services IDs.

Example "affected services" field data



The IF-Block  will be executed if all the affected services have been removed from the ticket. The Approver groups  field will be cleared.

The advance (for each) branch will allow us to iterate over the values (could be multiple services affected).

Next, we send a web request to JSM service registry API to pull more details of the services IDs listed under the Affected Services  field.

https://{{baseURL}}.atlassian.net/rest/service-registry-api/service
Paylod:
{
"ids": ["{{x}}"]
}

Then, we extract the ID of the approver group for this particular service from the web response of the previous web request. We will use this ID in the next step to pull the name of the approver group which is required to add/remove approver groups.


{{webResponse.body.services.get(0).jsmApprovers.groups.get(0).id.substringAfter("ari:cloud:identity::group/")}} 

Now, we clear any contents of the "Approver Groups" field so that we can store only those groups which belong to a service listed in the affected services .


{
    "update":     {
      "Approver groups": [{ "add": { "name": "{{webResponse.body.values.get(0).name}}" }}]
    }
}

Automation rule exported .JSON file

automation-rule-20848410-202408251425.json

Reference documentation links:

|


Last modified on Aug 29, 2024

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.