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

Retrieving User Profile info via Jira Cloud Automation

admin-nwalter
Contributor
June 21, 2024

My main goal is to be able to retrieve the information that is displayed on the user profile in Jira and apply those values within a Jira ticket, so when a ticket is created, this info is auto-populated in assigned custom fields. However, despite our Jira Cloud being synced with AzureAD, this info is not retrievable through automation. An alternative found way is through API.

 

I have created an Automation that basically does the below:

When: Issue is created

Then: Create Variable

  • - Variable name: ReporterEmail
  • - SmartValue: {{reporter.emailAddress}}

AND: Send Web Request

  • - HTTP Method: POST
  • - Web Request Body: Custom Data
  • - Custom Data: Clientcredentialsandsecret
  • - Header:
    • Key: Content-Type / Value: application/x-www-form-urlencoded

AND: Create variable

  • - Variable name: AccessTokenTest
  • - Smart Value: {{webhookResponse.body.access_token}}

AND: Send Web Request

AND: Add value to the audit log.

  • - Log message: {{webhookResponse.body}}

AND: Edit issue - Jobtitletest: {{webhookResponse.body.jobTitle}}

 

The automation runs successfull, but unfortunately it populates the customfield with literally the value "{{webhookResponse.body.jobTitle}}". The expected result was that it would retrieve the jobtitle from the webhook's response body, but it didn't. How can I achieve this? Again to reiterate, my goal is to map the user info that you can see in the User Profile within Jira, to custom fields within a ticket, every time a ticket gets created within the ITSD project. I do not want to use third party apps of any kind because we don't have the budget for that. Please help and apologies in advance if I didn't explain properly. 

1 answer

1 accepted

1 vote
Answer accepted
Bill Sheboy
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.
June 21, 2024

Hi @admin-nwalter 

As you are showing a manually typed in version of your rule, versus images of the rule and audit log, the community will need to guess a bit in order to help...

 

In the rule you describe, you write this value to the audit log in the second-to-last step:

AND: Add value to the audit log.

- Log message: {{webhookResponse.body}}

Does that write to the audit log contain what you expect?

 

Next, you state that Edit Issue action at the end of the rule, apparently of the field Jobtitletest, is writing the smart value expression rather than the value of that expression.  Have you confirmed that smart value expression is correct and has no typographical errors?

 

Kind regards,
Bill

admin-nwalter
Contributor
June 24, 2024

Hello @Bill Sheboy ,

Apologies for that. I didn't think the screenshot would contain sufficient info or would be sufficient:

Screenshot_997.png

To answer your question, the second to last option (adding value to the audit log) does bring a result, but actually shows the Access Token instead of what I expected.

 

Regarding your last question, i had found documentation that this was possible, but I am not able to find it any more. Not sure if this idea was a fever dream or exhaustion. 

Bill Sheboy
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.
June 24, 2024

Thanks for that information to confirm the rule structure.

The Issue Created trigger can fire so quickly that some information may not be available to the rule yet.  I recommend adding the Re-fetch Issue immediately after the trigger to prevent any timing problems with it.

Next, do each of your Send Web Request actions have the option enabled to wait until the response occurs?  It is this checkbox: "Delay execution of subsequent rule actions until we've received a response..."

Finally, I wonder if {{webhookResponse.body.jobTitle}} in your Edit Issue action is not parsing correctly, particularly if the rule is not recognizing it as well-formed JSON.  That can be confirmed by also writing just that expression to the log.  The workaround may be to use the match() function with a regular expression to parse the body: https://support.atlassian.com/cloud-automation/docs/jira-smart-values-text-fields/#match--

Like # people like this
admin-nwalter
Contributor
June 27, 2024

Dear Bill,

I think the re-fetch issue did trick combined with the "Delay execution" which was not active for the second Web Request. The logged actions now display the right options and the field is populated correctly now.

This opens up a lot of possibilities for now. Much obliged!

Like Bill Sheboy likes this

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