Forums

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

Populating an issue field with a specific Asset attribute

Robert Hook March 13, 2024

I have been trying to figure out a way to get an issue reporter's phone number into a custom field within the issue. I realize Atlassian doesn't store phone number in its User data, so that takes out the simple smart value route like you are able to do with {{reporter.emailAddress}}. I added users as an asset object and imported everyone from our organization into it along with their phone numbers as an object attribute. I realize this requires me to manually add/import any new hires into the Users objects, but I don't mind that piece since we are a relatively small organization.

I cannot seem to get that specific attribute to display in an issue field though. The Users asset object is set up as shown below:
Jira1.jpg

Jira2.jpg

I can point a query to the user to match the issue reporter by using
objectType = "Users" AND "Jira User Name" = currentReporter()

I don't know where to go from there to get to the phone number (or whether I am totally barking up the wrong tree). I tried various attempts with automation to pull in the phone number, namely by using an AQL query and then trying to reference its value with the {{lookupObjects}} smart value, but I seem to be failing at directing it to that specific attribute. Clearly I am a novice with queries and have no SQL or similar background to reference. There also may be a much easier way to accomplish what I am after, but I am the only person in our organization who has been willing to explore Jira's functionality.

1 answer

1 vote
Fernando Eugênio da Silva
Community Champion
March 13, 2024

@Robert Hook , Welcome to the Atlassian Community!

If you are using any Jira fields associated with Assets, you can iterate over the project using the following value:

{{issue.customfield_XXX.Attribute}}. In your case, {{issue.customfield_XXX.Office Phone}}

XXX it is related to field id created.

But if you want to do it without using an Assets field, you can get this.

In your automation that search for AQL objects, select this: ObjectType = Users AND Name IN ("{{issue.reporter.displayName}}")

This will get the object in your AQL that corresponds to the name of the user who created the issue in Jira

Then you can use the same logical object indentation feature using the following:

{{lookupObjects.Office Phone}}

It is expected that your AQL search will only bring up one object associated with the user, so the Office Phone will be from the same user retrieved in Assets. This AQL automation depends on your users' names in Jira matching the Names you assigned in Assets

 

Let us know if you have any questions

Kind Regards,

Fernando

Ashley Honeycutt
Contributor
October 29, 2024

Hi @Fernando Eugênio da Silva

Do you happen to have an example of how this automation would be set up? I'm trying to accomplish something similar to OP (displaying an attribute of an "Employee" object) on the view screen of an issue, but I'm getting stuck. I'm new to using Jira automation with Assets so I think seeing an example would help me understand better.

 

Robert Hook October 29, 2024

@Ashley Honeycutt we probably need a bit more details about the attribute you are trying to display and where you are trying to display it within an issue (Is it in a custom field? Part of a comment? In a native Jira field?). But I can show you how I accomplished the scenario I originally asked about above.

We have a Jira Assets object type of Users that has attributes for typical employee information like email, phone, manager, etc. You can see we have an attribute called "Jira User Name" which is a User type attribute, which is important later in this explanation. Here is the screenshot of how the Users object is set up for us in Assets.

JiraUserObject.png

My automation was to populate the email address and phone number for the reporter of the Jira issue. We set up custom fields in the issues for Reporter Email and Reporter Phone to display those values.  So the automation looks like this:


JiraAutomation1.png

It triggers when the value for the field Reporter is updated on the issue in some way. Jira already stores the email address for the reporter, so we did not need to use Assets to get that value. So the automation edits the Reporter Email field on the issue by using the native Jira smart value {{reporter.emailAddress}}. For the phone number, we do leverage Assets. We do a Lookup Objects step, and the AQL is set to search the Users objects for the custom attribute Jira User Name (as in the first screenshot) and match it to the native Jira smart value {{reporter.accountId}}. So then we edit the Reporter Phone field and populate it with {{lookupObjects.Phone}}...that step is using the object it found in the Lookup objects step and grabbing the Phone attribute from it. The last part of the automation is to do the same for a mobile phone number.

Hopefully this helps. If you can provide more details about how your Employee object is set up, what attribute from it you are trying to capture, and into what field/what type of field in the issue you are trying to populate it, then I  - or someone much smarter than me - can try to give you a bit more specific advise.



In a more general sense, if you had an employee named Brad Pitt, and his Employee object in Jira Assets was set up like this:
bradpitt.png

Then when you do a Lookup objects step in an automation and use the AQL...

          objectType = Users AND Name = “Brad Pitt”

...then the above Assets object for Brad Pitt would now be temporarily stored within the automation as the smart value {{lookupObjects}} . Additionally, you can reference specific information about Brad Pitt by using {{lookupObjects.attribute}} . So then:

 

{{lookupObjects.Legal Name}} would produce Bradley Pitt

{{lookupObjects.Phone}} would produce 555-861-2243

{{lookupObjects.Manager}} would produce George Clooney

Etc.

So if you had a field in an issue called Full Name where you were trying to get his Legal Name populated, you would have a step in the automation of Edit issue, then you would choose the Full Name field from the drop down in that automation step, and the value you would populate it with would be {{lookupObjects.Legal Name}}

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events