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

Automation: For each Affected Service... How to get Service ID and Name by ID

TL;DR: I managed to find a way to get IDs and Names of the Affected Services and use those values for Sub-Task creation. It's much harder than it sounds and should be ;)



I am very excited to announce, that I just figured out a way (with the help of the Atlassian Support and some other Community users) to use the "Affected Services" in Automation rules - and not just the If-Conditions that are available by default.

To be clear - the Article is referring to the "Services" Feature in JSM, not Assets! I work with a Standard Plan where Assets is not available.

Screenshot 2024-01-23 170031.png

 

What I wanted to achieve: The Agents are specialized in answering requests for one specific service each. Therefore we have different Queues filtering for the different Services. Customers will raise requests via the Portal regarding several Services. The Issue created will therefore appear in all Queues by standard. For some Request Types we want to filter out the Parent Issue and instead create Sub-Tasks for each Affected Service in the Parent, so the individual Agents can work on their respective Issue.

What I need for that: The Sub-Tasks will need the Affected Service filled by only one of the Affected Service Values from the parent. So for

Parent: DEMO-1 with Summary = xyz and "Affected Services" = ABC, Test

I need 

Sub-Task1: DEMO-2 with Summary = "Request for ABC" and Affected Services" = ABC
Sub-Task2: DEMO-3 with Summary = "Request for Test" and Affected Services" = Test

First Steps: What was fairly easy to achieve was to Branch over the Affected Services Field and create a Subtask for each Service with the Service in the Summary. The tricky part was, that you need the split-Function to actually get separate Values. You can then use the Variable for the Sub-Task creation and use the Service's name.

Screenshot 2024-01-23 170903.png

The trouble with the ID: To set the Affected Services field though, you need the ID. However, the ID you can retrieve via the UI in the "Services" section is not the ID you need here - don't ask me why. Instead, you need to access the ID via the API - hence you need a Webrequest.

Believe me, I tried - so you don't have to ;) 

Accessing the ID and the corresponding Name: 

1. Get the Issue per WebRequest

Replace the black area with your Cloud-Site.

Important: Check the "Delay execution" Button

For Authorization: Create a User API Token in your profile (or whoever executes the Rule). You will then need to Base64 encode your Email and Token -> EncodeBase64(Email:Token), add "Basic" in front of it and then your done - simple, innit?

Tipp: You can validate the Webrequest before you continue with the other Steps

 

This Webrequest will only return the ID of the Service, nothing else!

Screenshot 2024-01-23 171525.png

 

2. Branch over the Result

Replace the ID of the Customfield ID with the ID of the "Affected Services" field in your instance.

Screenshot 2024-01-23 172010.png

 

3. Find the names of the Services by ID

Use the "Send web request" Action again. This time we will use an undocumented API :) Replace the Site-name and the Auth Token as per the description in 1. 
We ask for Info on the Service with the ID "Affected", which is the Smart Value resulting from the Branch-Action.

Screenshot 2024-01-23 172345.png

 

4. Access the Service Name

Because the query only contains one ID at a time, the result will only contain one Service with one name. The Name is accessed like so:

Screenshot 2024-01-23 172603.png

 

5. Use the ID and Service to update issues

In my case, I am creating Sub-Tasks with the Servicename in the Summary and setting the Affected Services field with the ID. That looks like this:

Screenshot 2024-01-23 172848.png

 

The rule in all its glory:

Screenshot 2024-01-23 172920.png

 

Learnings:

  • The ID in the Services Tab is useless for Automation.
  • There are undocumented APIs, that are mighty.
  • Checkboxes sometimes make a huge difference.

 

I hope this helps someone save some time and I am happy to answer any detailed questions in the comments. This article is way too long as it is.

0 comments

Comment

Log in or Sign up to comment
TAGS
AUG Leaders

Atlassian Community Events