How can i access the particular customfield fields value like I want to get approver field accountId value then how can we access that.
Hi,
Basically, what the rest call resturn is a JSON response.
First, try and do the call in Postman or another client where you can inspect the result.The response might look something like this for the Approvers field:
{ "expand": "renderedFields,names,schema,operations,editmeta,changelog,versionedRepresentations","id": "10083","self": "https://<your-site>.atlassian.net/rest/api/3/issue/10083","key": "AUTBL-26","fields": {"customfield_10003": [ {"self": "https://<your-site>.atlassian.net/rest/api/3/user?accountId=557058:fbb39111-6fb5-4fa3-acca-2807f563c6df","accountId": "<the account ID here>","emailAddress": "someEmail@email.com","avatarUrls": {"48x48": "https://avatar-management--avatars.us-west-2.prod.public.atl-paas.net/557058:fbb39111-6fb5-4fa3-acca-2807f563c6df/55d30f27-0da5-45da-a670-91e420673421/48","24x24": "https://avatar-management--avatars.us-west-2.prod.public.atl-paas.net/557058:fbb39111-6fb5-4fa3-acca-2807f563c6df/55d30f27-0da5-45da-a670-91e420673421/24","16x16": "https://avatar-management--avatars.us-west-2.prod.public.atl-paas.net/557058:fbb39111-6fb5-4fa3-acca-2807f563c6df/55d30f27-0da5-45da-a670-91e420673421/16","32x32": "https://avatar-management--avatars.us-west-2.prod.public.atl-paas.net/557058:fbb39111-6fb5-4fa3-acca-2807f563c6df/55d30f27-0da5-45da-a670-91e420673421/32" },"displayName": "Jeroen Poismans","active": true,"timeZone": "Europe/Brussels","accountType": "atlassian" } ] }}
As you can see the Approvers field returns an array of objects. So let's try this:
def customfields1 = customFields[0].accountId
Hope this points you in the right direction!
Jeroen
yes i tried in this way too but in post-function script runner it shows warning like this
Ok, never mind the type error and lines ... Those are probanly there because of type checking.
I saw an error in my code, try something like this:
def customfields1 = customFields.fields.customfield_10507[0].accountId
Regards,
No Jeroen there is still type checking errors exist
btw why you are accessing 0th index of array object however the approver field account id is at first index i think.
It looks like you're new here. Sign in or register to get started.