Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Access information form Status Approved System Comment in a Filter, Dashboard or Field

Edited

When using Approvals in Jira Service Management, a Status approved comment is added as a system comment by Jira when someone approves an issue.  I would like to have this same information to be displayed on a dashboard that shows who all has or has not approved each issue. I have tried to write a JQL that will list the Status approved Jira system comments but am unsuccessful.  The normal comment ~ or text~ does not return the results of issues with this comment.  I need to figure out how to copy this comment to a field in some way using a post function, script runner, automation, etc. so that I can use it in a filter.  I am open to any way that I can send this comment data to a dashboard.

 

Screenshot of Jira system comment:

Screen Shot 2021-11-29 at 1.38.14 PM.png

2 answers

2 votes
Ivan Lima Community Leader Nov 29, 2021

Hi @Eric Johnston, to some extent, I'm sure you can automate to achieve what you described. However, what type of report are you trying to get from that? If it's a report only, you might find an app to help you report on that, but I'm not sure if one gives you this view without tweaking it a bit. What's the analysis you're trying to pull up from that? I know it's not what you want, but why, in this case, couldn't you develop a JQL(s) to fetch the issues you're looking for?

I would simply like to pull the user and status of each approval (like in the example screenshot above).  Ideally, I would like to copy the user and status of each approval to a field so that it can be displayed on a filter results gadget of a dashboard. I can create a script to copy that comment to a field but have been unable to access the comment with JQL or Scriptrunner as it is a Jira System field and I have not found a way to access the comment.  With this said, if there is a different way to achieve the same results, that is fine, please let me know.

The end result is to have a Jira Dashboard that will list any open issue(s) that requires approval to display the current user(s) and the status of each required approval.  I would prefer this not be an external report or separate dashboard but instead, use a gadget on an existing dashboard.

Ivan Lima Community Leader Nov 29, 2021

Understood. Well, you can get the data your looking for via APIs, but you'd need to put some thought into that. As I said, I'm sure you can get something together, but it's almost like developing an app fragment to achieve that. I'd suggest exploring marketplace apps and functional alternatives before going down this route. Anyways, you can get the data you're looking for via the get issue API, for example.

https://your-domain.atlassian.net/rest/api/3/issue/{issueIdOrKey}

You can access the Approvals custom field. You should see something like the screenshot below.

Screen Shot 2021-11-29 at 8.27.38 PM.png

You can then iterate over your approval history for a particular issue, where you can get the approval details.

Screen Shot 2021-11-29 at 8.29.43 PM.png

@Miquel White I am working on a way to do this and will post a solution once I get it working.

@Miquel White  We have figured out a way to do this.  My colleague will update this thread with our solution. Hope it helps you.

@Miquel White 

 

We were able to come up with a solution to this problem that involves the Automation for Jira extension, please see the following steps:

 

Determine the following custom field id numbers. (I will be using my customField id’s in this tutorial.)

 

Approvers: customfield_10003

Approvals: customfield_10026

ApproverCt: customfield_10597

Approval Status: customfield_10594

 

The description of what each of these fields are for are listed below:

 

Approvers is a field that we set up as a multiuser picker.

Approvals is the system field that’s locked.

ApproverCt is a custom field that was created be populated with the total number of values selected in the Approvers custom field

Approval Status is a multi-text custom field that we create to populate with the approvers name – status ( Note: you must set the field configuration so that the Approvals Status Field uses the Wiki Style Renderer) for the smart value to properly format in the next steps.)

 

In the Jira automation tools I we create rule that’s triggered by a Schedule that uses the following conditions:

 

Every 5 minutes run a JQL Search on the JQL Query Status = ‘Approvals’  

In our case when a ticket is in the status Approvals, the approvers are making their decision on whether to approve or reject a ticket.

 

We then added an Edit Issue field component to the automation to set the field Approvers Ct to the value returned by the smart value {{issue.customfield_10003.size}}

 

This value is the count of the number of approvers in the approvers custom field.

 

Add in a re-fetch issue data component to re-pull the newly updated field value for use further down in the automation.

 

Create a series of if matches statements using the possible Approvers Cnt values.

 

Example:

 

If: Matches Approvers Cnt equals 1

Then Edit issue fields Approval Status and set approval status field to the following value:

 

{{issue.customfield_10026.approvers.get(0).approver.get(0).displayName}} - {{issue.customfield_10026.approvers.get(0).approverDecision.get(0)}}\\

 

 

If: Matches Approvers Cnt equals 2

Then Edit issue fields Approval Status and set approval status field to the following value:

 

 

{{issue.customfield_10026.approvers.get(0).approver.get(0).displayName}} - {{issue.customfield_10026.approvers.get(0).approverDecision.get(0)}}\\

{{issue.customfield_10026.approvers.get(0).approver.get(1).displayName}} - {{issue.customfield_10026.approvers.get(0).approverDecision.get(1)}}\\

 

If: Matches Approvers Cnt equals 3

Then Edit issue fields Approval Status and set approval status field to the following value:

 

{{issue.customfield_10026.approvers.get(0).approver.get(0).displayName}} - {{issue.customfield_10026.approvers.get(0).approverDecision.get(0)}}\\

{{issue.customfield_10026.approvers.get(0).approver.get(1).displayName}} - {{issue.customfield_10026.approvers.get(0).approverDecision.get(1)}}\\

{{issue.customfield_10026.approvers.get(0).approver.get(2).displayName}} - {{issue.customfield_10026.approvers.get(0).approverDecision.get(2)}}\\

 

 

For each new Approvals count value continue to increment the smart values using the format above.

When we look at the value in the Approvals Status field after the JQL is ran we should see values similar to the following. This example references the If: Matches Approvers Cnt Equals 3.

 

Alex Sprague - Approved

David Reaves - Approved

Eric Johnston - Pending

 

If anyone has any suggestions on optimization or another method to solve this, please post it.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
TAGS
Community showcase
Published in Jira Service Management

JSM Jira Automation: How to Send SLA Breached Notifications

Hi Everyone, In   this tutorial,  we will show you how you can monitor an SLA, and send notifications before or after the SLA has been breached.   SLA Threshold Trigger The SLA t...

779 views 5 13
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you