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

How to get approval dates

Madar_ Andrew
Contributor
June 27, 2024

 

Hi everyone,  

I need to get the approvers approval date.  I can get the name and decision using the following but cannot figure out how to get the approval date.  I checked the API get and I should be able to.  Any ideas?

 

This gets the approval area, final decision, approver name and their decision.

{{#issue.Approvals}} Approving Area: {{name}} Final Decision: {{finalDecision}} {{#approvers}} Name: {{approver.displayName}} Approver Decision: {{approverDecision}} {{/}} {{/}}

 

This area I cannot get the date the approval was created.

 

{{#issue.Approvals}} {{createdDate.epochMillis}} {{createdDate.friendly}} {{createdDate.iso8601}} {{createdDate.jira}} {{#createdDate}} {{epochMillis}} {{friendly}} {{iso8601}} {{jira}} {{/}} {{/}}

 

In the API call, I can see createdDate but when I pass various keys none seem to work as expected.  Anyone have a luck getting this or suggestions on my format?

 

 

 

{ "_expands": [], "size": 3, "start": 3, "limit": 3, "isLastPage": false, "_links": { "base": "https://your-domain.atlassian.net/rest/servicedeskapi", "context": "context", "next": "https://your-domain.atlassian.net/rest/servicedeskapi/request/2/approval?start=6&limit=3", "prev": "https://your-domain.atlassian.net/rest/servicedeskapi/request/2/approval?start=0&limit=3" }, "values": [ { "id": "1", "name": "Please approve this request", "finalDecision": "approved", "canAnswerApproval": false, "approvers": [ { "approver": { "accountId": "qm:a713c8ea-1075-4e30-9d96-891a7d181739:5ad6d3581db05e2a66fa80b", "name": "qm:a713c8ea-1075-4e30-9d96-891a7d181739:5ad6d3581db05e2a66fa80b", "key": "qm:a713c8ea-1075-4e30-9d96-891a7d181739:5ad6d3581db05e2a66fa80b", "emailAddress": "fred@example.com", "displayName": "Fred F. User", "active": true, "timeZone": "Australia/Sydney", "_links": { "jiraRest": "https://your-domain.atlassian.net/rest/api/2/user?username=qm:a713c8ea-1075-4e30-9d96-891a7d181739:5ad6d3581db05e2a66fa80b", "avatarUrls": { "16x16": "https://avatar-cdn.atlassian.com/9bc3b5bcb0db050c6d7660b28a5b86c9?s=16&d=https%3A%2F%2Fsecure.gravatar.com%2Favatar%2F9bc3b5bcb0db050c6d7660b28a5b86c9%3Fd%3Dmm%26s%3D16%26noRedirect%3Dtrue", "24x24": "https://avatar-cdn.atlassian.com/9bc3b5bcb0db050c6d7660b28a5b86c9?s=24&d=https%3A%2F%2Fsecure.gravatar.com%2Favatar%2F9bc3b5bcb0db050c6d7660b28a5b86c9%3Fd%3Dmm%26s%3D24%26noRedirect%3Dtrue", "32x32": "https://avatar-cdn.atlassian.com/9bc3b5bcb0db050c6d7660b28a5b86c9?s=32&d=https%3A%2F%2Fsecure.gravatar.com%2Favatar%2F9bc3b5bcb0db050c6d7660b28a5b86c9%3Fd%3Dmm%26s%3D32%26noRedirect%3Dtrue", "48x48": "https://avatar-cdn.atlassian.com/9bc3b5bcb0db050c6d7660b28a5b86c9?s=48&d=https%3A%2F%2Fsecure.gravatar.com%2Favatar%2F9bc3b5bcb0db050c6d7660b28a5b86c9%3Fd%3Dmm%26s%3D48%26noRedirect%3Dtrue" }, "self": "https://your-domain.atlassian.net/rest/api/2/user?username=qm:a713c8ea-1075-4e30-9d96-891a7d181739:5ad6d3581db05e2a66fa80b" } }, "approverDecision": "approved" } ], "createdDate": { "epochMillis": 1475046060000, "friendly": "Monday 14:01 PM", "iso8601": "2016-09-28T14:01:00+0700", "jira": "2016-09-28T14:01:00.000+0700" }, "completedDate": { "epochMillis": 1475134200000, "friendly": "Today 14:30 PM", "iso8601": "2016-09-29T14:30:00+0700", "jira": "2016-09-29T14:30:00.000+0700" }, "_links": { "self": "https://your-domain.atlassian.net/rest/servicedeskapi/request/2/approval/1" } },

https://developer.atlassian.com/cloud/jira/service-desk/rest/api-group-request/#api-rest-servicedeskapi-request-issueidorkey-approval-get

 

2 answers

0 votes
Julian Governale
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.
July 2, 2024

A workaround that might work and is what we do since we have a three-stage approval is the following.

When the approval happens "Approved/Denied" the issue can be automatically transitioned, what you can do to capture that approval date and time is the following

First Option

  1. Trigger: Approval Complete
  2. Condition: If-Else
    1. If status = "Apprvoed Status"
      1. Edit Issue: set field "Approval Date/Time": {{now}}
    2. If status = "Declined status"
      1. Edit Issue: set field "Approval Date/Time": {{now}}

 

Second Option

  1. In your workflow transition for an approved and declined transition
  2. Set a Post Function to set the "Approval Date/Time Field" to {{now}}

 

This works well for us as we capture this field as read-only on an approval tab, and capture the initiator. (Who approved or declined).  If you set this into a date/time field, the system will automatically convert that date time to the local of the user viewing.

Since ours is a three-stage approval process (Service Owner, Business Owner, Change Board Approval) after each approval (approved) we transition to routing status to evaluate if the ticket needs to go to Business approval or can go right to our Change board approval so instead of doing the trigger on "Approval complete" we do it from "Service Owner Approval" to "Routing" and so on.

0 votes
Darryl Lee
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 28, 2024

Hey @Madar_ Andrew - yeah I'm running into the same problem. What a bummer.

When I try outputting {{issue.Approvals}} or even {{issue.customfield_10042}} I get the same output, which does NOT appear to contain the createdDate or I think what you really wanted, completedDate for the approvals. This is what I get:

ServiceDeskApprovalsBean{
id='1',
name='Authorize',
finalDecision='approved',
canAnswerApproval=false,
approvers=[ApprovalDecision{
approverDecision='approved',
approver=UserBean{name='null',
key='null',
accountId='557058:55df3d50-d179-4d17-b747-bf1484246c4f',
emailAddress='null',
displayName='Darryl Lee',
active=true,
timeZone='America/Los_Angeles',
locale='null'}}]}

While it's not much fun, you could use web requests within Automation to query the API yourself and get what you want from there. This is well-documented here:

I would just update those instructions to advise that you check the "Hidden" checkbox next to the Authorization header.

Madar_ Andrew
Contributor
July 1, 2024

Thank you, I will try this approach.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events