Forums

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

Setting "Jira User" value through automation?

Michael Gormley April 1, 2025

We have an asset schema that holds user data and syncs daily from Azure AD. When a new hire joins the company, their account is created in AAD, and a corresponding object is created in this user schema with some basic info populated.

We have an automation that's triggered when new objects are created in this schema (when object created in the schema, if objectType = users) with the goal of populating some more fields that aren't provided in AAD.

I'm running into an issue trying to set the "Jira User" attribute in this automation. It's a user-type attribute which I think is complicating things, and I'm not able to simply add an edit-object step and set a value for the attribute. (I've tried things like {{object.Name}}, {{lookupUsers(Name).accountId}}, etc. but the audit log shows errors like "Attribute value is not valid on Objects" or just "Unable to update objects".)

Basically I want to search the values in Jira User for one that matches what's in the user's Name attribute, and set that. From what I've been able to find, assets automation might be able to accomplish this but that doesn't appear to be an option in our instance yet. Is there any way to do this with a regular automation in Jira Cloud?

1 answer

1 accepted

0 votes
Answer accepted
Manoj Gangwar
Community Champion
April 4, 2025

Hi @Michael Gormley,

You can do that using the automation rule.
Note: Modify the values of the objects and attributes as per your data.

Example-
1- Trigger Scheduled

2- Branch for AQL- write an aql like (objectType = Users and "Jira Account" is Empty"

3- Then add value to the audit log "User email: {{object.email address}}"  

4- Send web request:
URL- https://yourjira.atlassian.net/rest/api/2/user/search?query={{object.email address}}
Method: GET
Web request body: Empty
Check the box for the Delay execution
Key  - Authorization
Value- Basic and then generate an API token and paste (Example- Basic anNtxhsks2mhdhdddhdhfjfkf)

5- Again, add value to the audit log
(User API) Web Response = {{webResponse.body}}

6- Add {{smart value}} condition for compare two values
First value: {{webResponse.body.size}} Equal Second value: 1

7- Create Variable
Varibale Name: jiraUserAccountid
Smart Value: {{webResponse.body.accountId}}

8- Edit object
select attribute name Jira Account and add the value {{jiraUserAccountId}}

You try this. It should work.

Michael Gormley April 4, 2025

Hi @Manoj Gangwar , thank you for the suggestion. I'm going to see if I can get this working, I'm out next week but I'll follow up once I have a chance to fully test it.

Thanks!

Michael

Like Manoj Gangwar likes this
Michael Gormley April 28, 2025

After some minor tweaks around the branch action we've gotten a lot of this working.

One problem I'm still having though is around the web request. I configured the action and set up an API token and that all seems valid. Response code is 200 and shows "OK". I also get the expected data if I go to the URL myself (filling in a valid user's email address at the end), I can see their accountId, displayName, etc.

The issue is, webResponse.body.size is showing 0 instead of 1, so of course that smart value condition in step 6 fails and the object isn't edited. The behavior seems similar to another person's question (https://community.atlassian.com/forums/Jira-questions/Automation-for-Jira-Send-Web-Request-Body-is-empty/qaq-p/2740011).

I haven't been able to get past this point.

Any reason you can think of that body.size would still be 0? The validation on the web request step seems to be successful, the URL is correct, and manually going to the URL shows the expected fields.

Thanks again, I really appreciate your help getting this far!

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.
April 28, 2025

Hi @Michael Gormley 

For the Send Web Request action, did you check the option to Delay Execution of the remaining rule steps until the action completes?

Kind regards,
Bill

Michael Gormley April 29, 2025

Hi @Bill Sheboy 

Thanks for your response, but yes, delay Execution is already checked. I think I figured it out though, looks like it was a permissions issue.

I found a response from Atlassian on a similar issue here (https://community.developer.atlassian.com/t/unable-to-get-response-payload-in-automation/60721/5). Apparently Jira Cloud can allow anonymous access, so with my permissions it was showing a "valid" response but no payload. I asked a site admin to generate an API token and used that in place of mine, and everything works perfectly.

Thanks again, and huge thanks to @Manoj Gangwar too!

Like Bill Sheboy likes this

Suggest an answer

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

Atlassian Community Events