Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

how to extract the value of an asset attribute with nunjucks

Paul Wilkinson September 4, 2024

Hi

I need to find with a post-function the value of an attribute of an asset.

The structure I can see via this dump {{ issue | insightFieldValue("customfield_10131") | dump() }} is:

[
  {
    "id": "f7c6cc8b-439a-4dbd-9f07-1eb3156fc195:2",
    "objectKey": "TESTPR-2",
    "label": "Customer 1",
    "objectType": {
      "id": "f7c6cc8b-439a-4dbd-9f07-1eb3156fc195:8",
      "name": "Contract",
      "description": "Contact with Customer"
    },
    "attributes": {
      "Created": [
        {
          "value": "2024-09-04T09:58:42.847Z",
          "displayValue": "04/Sep/24 9:58 AM",
          "searchValue": "2024-09-04T09:58:42.847Z",
          "referencedType": false
        }
      ],
      "Updated": [
        {
          "value": "2024-09-04T10:46:11.770Z",
          "displayValue": "04/Sep/24 10:46 AM",
          "searchValue": "2024-09-04T10:46:11.770Z",
          "referencedType": false
        }
      ],
      "ResponseTimeTarget": [
        {
          "value": "30",
          "displayValue": "30",
          "searchValue": "30",
          "referencedType": false
        }
      ],
      "Contact Person": [
        {
          "value": "Franco",
          "displayValue": "Franco",
          "searchValue": "Franco",
          "referencedType": false
        }
      ],
      "Key": [
        {
          "value": "TESTPR-2",
          "displayValue": "TESTPR-2",
          "searchValue": "TESTPR-2",
          "referencedType": false
        }
      ],
      "Customer": [
        {
          "value": "Customer 1",
          "displayValue": "Customer 1",
          "searchValue": "Customer 1",
          "referencedType": false
        }
      ]
    }
  }
]

However this command seems to returns void (see attachment):

{{ issue | insightFieldValue("customfield_10131") | field("attributes.ResponseTimeTarget.value") }}

Screenshot 2024-09-04 at 13.17.12 (2).png

Can anyone tell me what I am doing wrong?

Thanks 

1 answer

0 votes
Marc - Devoteam
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 4, 2024

Hi @Paul Wilkinson 

This earlier post seems to be in-line with your request.

I might give you some direction.

https://community.atlassian.com/t5/Jira-questions/access-Asset-object-attributes-in-postfunction/qaq-p/2478493 

Otherwise you can always ask JMWE support.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
TAGS
AUG Leaders

Atlassian Community Events