access Asset object attributes in postfunction

Tom Lister
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 15, 2023

Hi 

I want to access attribute values in an Assets object i.e. address details for an email or store in a text field.

I am using JMWE at the moment but could also try Scriptrunner if there is a solution there.

I can see my object using

{{ issue | insightFieldValue("customfield_10076") | first | field("label") }}

But I want to get at the attributes. The structure I can see via a dump() is

{
"id": "ed27ff36-cae3-4680-979c-a7457da17e:3496",
"objectKey": "ITEM-3496",
"label": "Site 1",
"objectType": {
"id": "ed27ff36-cae3-4680-979c-a7757da17e:16",
"name": "Site"
},
"attributes": {
"country": {
"value": "England",
"displayValue": "England",
"searchValue": "England"
}
}
}

Any one else solved this?

2 answers

1 accepted

2 votes
Answer accepted
David Fischer
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 15, 2023

Hi @Tom Lister 

since this seems to be a single-value Insight field, you don't need to use the "first" filter (which is needed when the value is an array).

So to access the label of the Insight object, you can do:

{{ issue | insightFieldValue("customfield_10076") | field("label") }}

And for, say, the country name:

{{ issue | insightFieldValue("customfield_10076") | field("attributes.country.value") }}
Tom Lister
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 15, 2023

Brilliant - just the job

{{ issue | insightFieldValue("customfield_10076") | first | field("attributes.country.value") }}
Swapnil Srivastav
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
March 15, 2024

Hello @David Fischer ,

Thank you very much for sharing. I want to traverse through the values of a multi-value asset object field and compare the values with string values. Is it achievable with JMWE?

David Fischer
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 15, 2024

Hi @Swapnil Srivastav ,

yes, this is doable, you'll need to write some Nunjucks code, using the for statement:

{% for item in issue | insightFieldValue("customfield_10076") %}
{% if item.attributes.country.value == "some string" %}
SOME VALUE
{% endif %}
{% endfor %}
0 votes
Tom Lister
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 15, 2023

Progressing slightly.

I can see the attributes only using

{{ issue | insightFieldValue("customfield_10076") | first | field("attributes") | dump() }}

The question now is how filter the value for "country"

I can find it by "value"

{{ issue | insightFieldValue("customfield_10076") | first | field("attributes") | filter({value:"England"}) | first | dump() }}
 
{"value":"England","displayValue":"England","searchValue":"England"}

but i want to find specific values by attribute name

Felix Haverkamp
Contributor
June 14, 2024

@Tom Lister 

Currently struggeling with the same approach. 

----

{{ issue | insightFieldValue("customfield_10076") | first | field("attributes") | first | dump() }}

----

But attributes is always empty. 


maybe there is a way to get the asset attributes with the restAPI Filter "callRest" from JMWE

 

Felix Haverkamp
Contributor
July 4, 2024

@Appfire Support {Appfire} can you confirm that the field "attributes" is empty or is this a bug at jmwe or atlassians implementation?

Avinash Bhagawati {Appfire}
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 4, 2024

Hi @Felix Haverkamp , Good day!

Hello, this is Avinash from the Appfire Product Support Team.

I am currently reviewing your request and will provide you with updates through the support ticket you raised. Furthermore, I will also share the final outcome here.

 

Thank you,
Avinash

Avinash Bhagawati {Appfire}
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 8, 2024

Hi @Felix Haverkamp Good day!

We would like to update you that this issue has been fixed as part of our latest release. please validate again. Please let us know if you have questions. 

Thanks,
Avinash

Felix Haverkamp
Contributor
August 19, 2024

Solved:

I can confirm its working now.
In Nunchuck we have now very much information about the assets.

Remember: Nunchuck Templates are currently not available in conditions nor validators. That would be absolute great, but there is an issue at Atlassian Bug Tracker: https://jira.atlassian.com/browse/JSDCLOUD-12479

have a g´day

Suggest an answer

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

Atlassian Community Events