This appears to be a question which has already been asked however the answers I found did not relate to my particular situation.
I am writing a script using the app 'Scriptrunner' which has been installed on an instance of Jira Service Desk Cloud not server.
I am also writing this script in the context of a 'Post function', the script is triggered upon creation of a new issue
What I am trying to do with the script is:
1. Get the value of the custom field 'Market' from the created issue
2. Depending on the value found in the 'Market' field
3. Create a new custom field on the created issue and populate the value of the new custom field
The problem I am having is getting the values of the custom fields (I haven't got as far as setting a new custom field yet.
// Get all the fields from the issue as a Map
def fields = issue.fields as Map
log.debug("FIELDS:" + fields)
I get the fields by using the above snippet, it should return the following fields:
However the log output shows that the majority of the fields have the value 'null', see below:
2020-01-24 14:35:21.237 DEBUG - FIELDS:[customfield_10070:null, customfield_10071:null, customfield_10072:null, customfield_10073:null, customfield_10076:null, customfield_10077:null, customfield_10078:null, resolution:null, customfield_10079:null, lastViewed:null, customfield_10060:null, customfield_10061:null, customfield_10062:null, customfield_10063:null, customfield_10064:null, customfield_10065:null, customfield_10066:https://www.volkswagen.it/it.html, customfield_10067:https://www.volkswagen.it/it.html, customfield_10068:null, labels:[], aggregatetimeoriginalestimate:null, issuelinks:[[id:10280, self:https://vw-engine.atlassian.net/rest/api/2/issueLink/10280, type:[id:10003, name:Relates, inward:relates to, outward:relates to, self:https://vw-engine.atlassian.net/rest/api/2/issueLinkType/10003], outwardIssue:[id:12395, key:ES-485, self:https://vw-engine.atlassian.net/rest/api/2/issue/12395, fields:[summary:OPS - Automation of Jira processes, status:[self:https://vw-engine.atlassian.net/rest/api/2/status/3, description:This issue is being actively worked on at the moment by the assignee., iconUrl:https://vw-engine.atlassian.net/images/icons/statuses/inprogress.png, name:In Progress, id:3, statusCategory:[self:https://vw-engine.atlassian.net/rest/api/2/statuscategory/4, id:4, key:indeterminate, colorName:yellow, name:In Progress]], priority:[self:https://vw-engine.atlassian.net/rest/api/2/priority/3, iconUrl:https://vw-engine.atlassian.net/images/icons/priorities/medium.svg, name:Medium, id:3], issuetype:[self:https://vw-engine.atlassian.net/rest/api/2/issuetype/10006, id:10006, description:A task that needs to be done., iconUrl:https://vw-engine.atlassian.net/secure/viewavatar?size=medium&avatarId=10517&avatarType=issuetype, name:Task, subtask:false, avatarId:10517]]]]], assignee:[self:https://vw-engine.atlassian.net/rest/api/2/user?accountId=5be05eade3a3ee7e0823c2f9, accountId:5be05eade3a3ee7e0823c2f9, avatarUrls:[48x48:https://avatar-management--avatars.us-west-2.prod.public.atl-paas.net/i
As you can see the only custom fields I can get via the API are 'Website/Domain' and 'Page URL example' - Does anybody know how I can access ALL fields?
def issue = get("/rest/api/2/issue/${issueId}")
.header('Content-Type', 'application/json')
.asObject(Map)
.bodyJust to add I have used both the above method and the method detailed in my initial question.
Thanks in advance