Value of Insight object attribute in a custom field

Kölker, Finn September 2, 2022

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
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 5, 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

Kölker, Finn September 7, 2022

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

Guilhem Dupuy
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 7, 2022

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 ?

Kölker, Finn September 7, 2022

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

Kölker, Finn September 7, 2022

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
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 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