Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,364,190
Community Members
 
Community Events
168
Community Groups

Value of Insight object attribute in a custom field

Hello,

I have an Insight object type (Support Responsibility) with a Role attribute that is of the type User (multiple selection is possible).

How do I get the value of the Role attribute (the users) in a custom field of the type Multi User Picker? We plan to use the users in this custom field to manage notifications.
So far I've tried using Process Automation and Smart Values, but they only gave me access to the Key and Name attributes, and not custom attributes (such as Role).

How would you solve the problem (preferably without scripting).
Using Jira 9.1.0, on-prem.

Thanks in advance.

1 answer

1 accepted

1 vote
Answer accepted
Guilhem Dupuy Community Leader Sep 05, 2022

Hi @Kölker_ Finn ,

Indeed you can not retrieve the EmailAddress from an insight User attribute from a smart value, this is weird as this works for every other User custom field :) 

 

The workaround you could use is the following : you can populate a multi-user custom field based on the users in the attribute "Role" of your Insight object "Support Responsibility".

To do this, build an automation rule which edits your multi-user custom field. To edit the custom field, select the "Advanced" option and enter the following JSON : 

 

{
"fields": {
"NameOfYourCustomField": {{issue.customfield_XXXXX.Role.flatten.asJsonObjectArray("id")}}
}
}

 

Let me know if it works,

Guilhem

Hello,
Thanks for your answer!

Getting the users in Role 1 via the custom field does not work. But what we have done now is to send a web request via Project Automation that provides us with the data we need. Your suggested JSON formatting helped a lot.


The selector currently looks like this:

{{webhookResponse.body.get(6).objectAttributeValues.asJsonObjectArray("user.name")}}

And returns us this:


[
    {
        "user.name": "fkoelker"
    },
    {
        "user.name": "jdoe"
    }
]

 What I am currently failing at is making a list of user names from this array of JSON objects. So what I need would be at best:

["fkoelker", "jdoe"]

 

Do you have an idea on how to achieve that?

~Finn

Unfortunately I'm no JSON expert,

Are you sure getting the users in role 1 doesn't work ? I tried it on a test instance and it worked.

Can you please try to add a comment in an issue with the following smart value and tell me what you ou get ?

{{issue.customfield_XXXXX.NameOfYourInsightAttribute.flatten.asJsonObjectArray("id")}}

 

And with your API call you could try removing the "asJsonObject" part and see if it's better ?

Hello,
Thanks for your fast answer.

Using 

{{issue.customfield_16102.Role 1.flatten.asJsonObjectArray("id")}}

 the added comment's content is just "[]".

Or could it be that the key is wrong? Do you know if I can somehow display the Insight object in JSON format?

---

If I remove the "asJsonObjectArray" of my API call, the response gives me more information, that I do not need.
Using the API call I mentioned in my previous comment, I've narrowed down the content of the response as much as possible, which is what I was getting at.

~Finn

Hello,

It seems like I was just overthinking it. It was enough to enter the smart value

 {{webhookResponse.body.get(6).objectAttributeValues.user.name}}

in the custom field.

 

Anyway, I really appreciate your help.
~Finn

Like Guilhem Dupuy likes this
Guilhem Dupuy Community Leader Sep 12, 2022

Okay, good to know it ended up working for you !

 

Best of luck,

Guilhem

Suggest an answer

Log in or Sign up to answer