Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Automation for Jira and Affected Services

Dave Furlani
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 14, 2023

In Jira SM we have a project for change management and a Change issuetype. 

We also have a service desk project where Events issuetypes are created from monitoring tools are directed 

Both of these use the Affected Services field.

What I would like to do is use the time between the Deploying and Completed statuses on the Change issue to update all Events with the same Affected Services created in that time window.

This of course needs a lookup with JQL . That JQL will need the Affected Services set in the Change issue. 

Looking at a manually created JQL the service name gets converted to a very long ID, so I assume I'll need the same ID and not the display name to appear in the Lookup JQL based on {{triggerIssue.Affected Services}}, but this produces the human readable service name. I've tried many things that failed, and the following which produces display name.

{{#issue.Affected services}}{{.}}{{^last}},{{/}}{{/}}

There's probably a way to find the valid dot operators for any field, which a trick I'd love to learn, but I'll settle for the correct syntax in a pinch if you have it.

2 answers

1 accepted

0 votes
Answer accepted
Dave Furlani
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 28, 2024

Revisiting this idea and truing to find a solution and I found that the following syntax returns the long ugly IDs for each affected service on the ticket:

{{issue.affectedServices.serviceID}}

Expanding on that and breaking the output into a format that the JQL can use, the following syntax works. The double quotes are required to allow the JQL to consume the equals sign at the end of the service IDs. The ^last inserts double quotes and a comma between each affected service if there are multiple 

"Affected services" in ("{{#issue.affectedServices}}{{serviceID}}{{^last}}","{{/}}{{/}}")

 This produces valid JQL that can be used in a lookup within the A4J rule, and thus meets my initial requirement

Fares
Contributor
November 8, 2024

Hi Dave,

I'm looking to have an automation fill the Affected Service from a simple customer facing option type custom field and going nowhere.

I understand that you can't set an Affected Service with name only and need to use an ID. I'm not sure however how I should set up the automation to connect the basic dropdown to the correct ID.

I'm asking here because it seems you understood the inner workings of this thing.

Thank you.

Dave Furlani
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 10, 2024

May 2024 feels like half an ago ago, but from memory:

I was trying to find the ID of the system to build JQL. What I could have done, or would probably do now, is user the AQL query with the JQL.

A way find the AQL you need is to filter the object type of interest by the attribute you intend to ask the user for, e.g. Name (attribute) of Software (Object). Update the filter then look at the Advanced AQL tab. Copy the AQL text provided

When adding that into some JQL, you'll need to use the aqlFunction option and change the default double quotes to single quotes like so:

System in aqlFunction('"Name" IN ("AMS", "Hover", "MRM")')

Your options would then be to offer the relevant Asset field to your users to select from, or if you want to reduce their options further, so offer a drop down of statis options and use an A4J rule to translate those into the actual system names for the JQL

I hope that helps

Fares
Contributor
November 11, 2024

Thank you for the answer.

Do you think it's necessary to use Assets to do something like this ? We have not set up anything in that regard and I would need to set them up for this automation only.

I'm not even sure our Standard license covers Assets functionality. Lookup nodes on the automation page send 403 errors!

Fares

Dave Furlani
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 11, 2024

Assets is basically a CMDB in Jira. If your current need is only to allow users to select from a small range of systems, then I'd say you don't need it. If your organisation has needs for a CMDB and doesn't yet have one, having that data within Jira can be very helpful due to all the relationships between configuration items that it can hold and use in Jira JSM and A4J rules. A business case and cost-benefit analysis would be needed if you increase your licensing costs. But I digress

1 vote
Alex Koxaras _Relational_
Community Champion
September 14, 2023

Hi @Dave Furlani 

There is a way to get the ID of that service. And this is to use the "Send Web Request" component to get the issue and then drill down to get the Affected Services custom field, which includes the id of that service. Then use the {{webResponse}} smart value to get the id. It will look similar to this:

{{webResponse.body.fields.customfield_10039.id}}

Where on my instance customfield_10039 is the Affected Services field.

services id.png

I would agree that using a smart value, as you did, would be a much much easier way. However since that smart value returns the name of the service, I would say that it's going to be impossible to get the id..

Let me know if the above helps!

Dave Furlani
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 17, 2023

I tried that and I I got the same value by calling the API via https://<ourJiraURL>/rest/api/2/issue/DFXXREL-2?expand=names. That gave me an ID value in a format like yours.

"ari:cloud:graph::service/a711ac5c-6127-11eb-b9be-0abe3f4a6601/463983dc-da2a-11ec-b4c3-0abe3d4a6601"

57426c66-08ee-45cf-b847-db4069b08f85.png

Sadly, this ID value does not work in a JQL search.

When creating the JQL, it converts the service name (e.g. CRM) into a longer, uglier key, like this, which I don't see in the API response, and I'm not sure how it's generated.

"b:YXJpOmNsb3VkOmdyYXBoOjpzZXJ2aWNlL2E3MTFhYzVjLTYxMjctMTFlYi1iOWJlLTBhYmUzZjRhNjYwMS80NjM5ODNkYy1kYTJhLTExZWMtYjRjMy0wYWJlM2Y0YTY2MDF="

download.png

Suggest an answer

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

Atlassian Community Events