get a specific attribute of a field

Jan Hidding
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!
November 25, 2024

I have a customfield object and I want to get the value of an attribute of that field.

For instance I have the custom field "customfield_10010" with attribute "requestType". With the field parameter I get the total custom field object, but I want only the "customfield_10010": { "requestType" } value.

Is that possible.

2 answers

0 votes
PRAMOD KUMAR REDDY KASIREDDY
Contributor
November 25, 2024

Hi @Jan Hidding,                                                                                                              Yes, the value of an attribute may be extracted from a Jira custom field object, as long as the field's data structure contains the requested property. This frequently entails obtaining the field's value and then traversing through its data structure to extract the desired property.

Example Approach in Groovy
If you're using ScriptRunner and want to extract the requestType property from a custom field (such as "customfield_10010"), here's how:

1. Retrieve the custom field value.
Use Jira's API to get the value of a custom field for a particular issue.

2. Access the desired attribute.
If the field's value is a JSON object or has a hierarchical structure, parse it to retrieve the desired property.

0 votes
Rik de Valk
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
November 25, 2024

Hi @Jan Hidding , 

Reading your question I suspect you mean you want to fetch the value of a custom field for a specific Issue

If so, you need to get the Issue object instead of the Custom Field object. 

The Custom Field object is the abstract, generic Field which can be added to a Screen and only has attributes such as Type (text, single select, user, number etc). But the Field object will never have an actual value. 

See https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-issues/#api-rest-api-2-issue-issueidorkey-get

Hope that helps. 

Have a nice day!

Rik

Suggest an answer

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

Atlassian Community Events