/** This example script console script returns the name and key of the linked EPIC based on the value from the Epic Link Field on the issue .* "All right, title and interest in this code snippet shall remain the exclusive intellectual property of Adaptavist Group Ltd and its affiliates. Customers with a valid ScriptRunner* license shall be granted a non-exclusive, non-transferable, freely revocable right to use this code snippet only within their own instance of Atlassian products. This licensing notice cannot be removed or* amended and must be included in any circumstances where the code snippet is shared by You or a third party." */// Specify the issue key belowdefissueKey="<IssueKeyHere>"// Get the custom fields for the Jira InstancedefcustomFields=get("/rest/api/2/field").asObject(List).body.findAll{(itasMap).custom}asList<Map>// Get the Id for the Epic Link and Epic Name fields defepic_link_Id=customFields.find{it.name=='Epic Link'}?.id// Get all of the field values from the issuedefissue=get('/rest/api/2/issue/'+issueKey).header('Content-Type','application/json').asObject(Map)// Get the value from the Epic Link Fielddefepic_link_value=issue.body.fields[epic_link_Id]// Get the Epicdefepic=get("/rest/agile/1.0/epic/${epic_link_value}").header('Content-Type','application/json').asObject(Map)// Get the name from the returned Epic defepic_name_value=epic.body.nameasStringdefepic_key_value=epic.body.keyasString// Print out the returned name on screenreturn"Epic Name = ${epic_name_value} and Epic Key = ${epic_key_value}"
Comments (0)
HTTPSSSH
You can clone a snippet to your computer for local editing.
Learn more.