Match users in CSV import to user type attribute of Assets objects
Platform Notice: Cloud Only - This article only applies to Atlassian apps on the cloud platform.
Summary
Learn how to import users as attribute values in Assets Cloud using Atlassian Account IDs.
Solution
Find the Atlassian Account ID for users
To obtain the Atlassian Account IDs in your site, you can export all users into a CSV file. To do so, navigate to yoursitename.atlassian.com/admin/users > Export users. Once you have the account IDs, update the objects with the corresponding Jira users in your file.
Use automation to update the user attribute based on email addresses
Let's say you have an object type called "Person" that has the attributes:
"Jira User" of type "User" - this attribute needs to be updated with the corresponding Jira user for that object.
"Manager" of type "Object" - this attribute is self-referenced and stores the manager object of the user.
"Jira Manager" of type "User" - this attribute needs to be updated with the corresponding Jira user of the manager for that object.
"mail" of type Text - stores the email address of the user.
These steps will help you update the "Jira User" attribute with the corresponding user by fetching the user details using the email address stored in the "mail" attribute:
Create a global automation rule that triggers when an object is created. (You can also use the scheduled trigger followed by a Branch on AQL).
Create a Branch on AQL. Choose the desired schema and specify the AQL:
Add two Create variable actions and create these variables:
Variable 1:
name: EMAIL
Smart value:
{{object.email}}
Variable 2:
Name: emailManager
Smart value:
{{object.Manager.mail}}
Add a Send web request action to get the User account ID using the search user API:
Web request URL:
https://<Cloud site URL>/rest/api/3/user/search?query={{EMAIL.urlEncode}}
Configure three Headers:
Content-Type: application/json
Accept: application/json
Authorization: In the Authorization header make sure that you add the keyword Basic followed by the base64 of your emailaddress:APItoken. So if the base64 of the emailaddress:APItoken is AB12XY45 then to the Authorization header add the value Basic AB12XY45.
HTTP method: GET
Web request body: Empty
Check the option "Delay execution of subsequent rule actions until we've received a response for this web request", as the response contains the user's Atlassian account ID.
Create variable in the rule to store the account ID of the user:
Variable name: AAIDUser
Smart value:
{{webResponse.body.accountID}}
Next, send a web request using Send web request action again. Use the same content from step 4 except for the Web request URL field which should be:
https://<Cloud site URL>/rest/api/3/user/search?query={{emailManager.urlEncode}}
⚠️ Make sure you check the option "Delay execution of subsequent rule actions until we've received a response for this web request"
Add another Create variable to store account id of the manager:
Variable name: AAIDManager
Smart value:
{{webResponse.body.accountID}}
Add an action to Edit object and set the attributes using the variables you just created:
Jira Manager:
{{AAIDManager}}
Jira user:
{{AAIDUser}}
Publish the rule.
You can edit the rule according to your requirements, for example, by removing those actions in case you do not have the manager attribute.
Update more than 50 objects
Automation has a limit where it can only update 50 objects at once. So, depending on the number of users you would like to update, it can happen that no new objects are picked by the branch as the "Jira user" remains empty for these objects.
In that case, you can add an attribute in the "Person" object type, say "Last Sync date" of type date, and use this to go through the objects that have not been synced since the last update. This value will help us iterate over all the objects using an automation rule, and the update will be performed only on those objects that have not been updated on that day.
After you have added the above attribute, you need to make changes to the above rule as below:
Update the AQL in branch as:
objecttype = "Person" and mail is not empty and "Jira User" is empty AND ("Last Sync date" < startOfDay() OR "Last Sync date" IS EMPTY)
This will only check those objects which have not been picked up by the automation rule on the same day.
In the Edit object action, add attribute "Last Sync date" and provide the value:
{{now.format("dd/MMM/yy")}}
This will update the attribute to store the date when the automation rule picked this object to check for the corresponding Jira user.
Another option is to make use of Dynamic Looping.
We have a feature request to expand the number of objects that can be updated per rule: JSDCLOUD-10643 - Ability to update more than 50 objects in a single Assets automation run.
For more examples refer to the article Update Asset object attribute values using automation
Was this helpful?