Hello,
I want to implement a scripted field similar to the one shown in the example code available on Adaptavist's website.
The thing is that this code is not actually working.
After investigation, it seems that calling the rest api with .queryString("fields", ) is not able to return an array with a customfield value. (it works well with all native fields).
See inputs and outputs
if (issue.fields.issuetype.name == "Epic") {
def fields = get('/rest/api/2/field')
.asObject(List)
.body as List<Map>
def ChiffrageTRATotal = 0
// Get all issues below the the Epic Issue
def allChildIssues = get("/rest/agile/1.0/epic/${issue.key}/issue")
.queryString("jql", "parentEpic =${issue.key}")
.queryString('fields', 'priority')
.asObject(Map)
.body
.issues as List<Map>
return allChildIssues
}Returns the field
[{
"expand": "operations,versionedRepresentations,editmeta,changelog,renderedFields",
"fields": {
"priority": {
"iconUrl": "https://<mysite>.atlassian.net/images/icons/priorities/low.svg",
"id": "4",
"name": "P3",
"self": "https://<mysite>.atlassian.net/rest/api/2/priority/4"
}
},
"id": "16615",
"key": "SEL-1669",
"self": "https://<mysite>.atlassian.net/rest/agile/1.0/issue/16615"
}, {
"expand": "operations,versionedRepresentations,editmeta,changelog,renderedFields",
"fields": {
"priority": {
"iconUrl": "https://<mysite>.atlassian.net/images/icons/priorities/blocker.svg",
"id": "2",
"name": "P1",
"self": "https://<mysite>.atlassian.net/rest/api/2/priority/2"
}
},
"id": "16833",
"key": "SEL-1712",
"self": "https://<mysite>.atlassian.net/rest/agile/1.0/issue/16833"
}
]
<span>But</span>
if (issue.fields.issuetype.name == "Epic") {
def fields = get('/rest/api/2/field')
.asObject(List)
.body as List<Map>
def ChiffrageTRATotal = 0
// Get all issues below the the Epic Issue
def allChildIssues = get("/rest/agile/1.0/epic/${issue.key}/issue")
.queryString("jql", "parentEpic =${issue.key}")
.queryString('fields', 'customfield_xxxx')
.asObject(Map)
.body
.issues as List<Map>
return allChildIssues
}<span>With <em>customfield_xxxx</em> being a valid non-empty custom field on the child issues of my epic.</span>
Returns:
[{
"expand": "operations,versionedRepresentations,editmeta,changelog,renderedFields",
"id": "16615",
"key": "SEL-1669",
"self": "https://<mysite>.atlassian.net/rest/agile/1.0/issue/16615"
}, {
"expand": "operations,versionedRepresentations,editmeta,changelog,renderedFields",
"id": "16833",
"key": "SEL-1712",
"self": "https://<mysite>.atlassian.net/rest/agile/1.0/issue/16833"
}
]With no mention to the field array nor customfield_xxxx.
How to fix that?
Thanks.