I have used a code I found to create a scripted custom field with scriptrunner that shows me the Epic Link in a issue and also a Sub-Task.
I now want the custom field to have the epic color as the background color, because we use the color to identify different categories of topics (to save a column on the dashboard we use for stand up meetings).
Currently the output of the field is:
Epic Name
I want:
![2019-06-12 10_35_26-[ENDO-6637] asdfasfsd - DBG JIRA.jpg 2019-06-12 10_35_26-[ENDO-6637] asdfasfsd - DBG JIRA.jpg](https://us.v-cdn.net/6038660/uploads/images/57322i7834D3DFB9ABCACD/2019-06-12%2010_35_26-%5BENDO-6637%5D%20asdfasfsd%20-%20DBG%20JIRA.jpg)
The code I used is:
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.issue.CustomFieldManager;
import com.atlassian.jira.issue.fields.CustomField;
import com.atlassian.jira.issue.Issue;
CustomFieldManager cfManager = ComponentAccessor.getCustomFieldManager();
CustomField epicLink = cfManager.getCustomFieldObjectByName('Epic Link');
CustomField epicName = cfManager.getCustomFieldObjectByName('Epic Name');
//This is where we store the issue that is linked to the epic.
Issue issue_linked_to_epic
/* determine if this is an epic, if so, return the epic link name */
if (issue.issueTypeObject.name == "Epic"){
return issue.getCustomFieldValue(epicName)
}
/*determine if this is a subTaskIssueTypes(), if so, set the parent to the issue linked to the epic */
Issue issueParent = issue.getParentObject()
if (issueParent == null){
issue_linked_to_epic = issue
} else {
issue_linked_to_epic = issueParent
}
/* get epic link */
Issue epic = (Issue) issue_linked_to_epic.getCustomFieldValue(epicLink)
if (epic == null){
return null
}
String epicNameString = epic.getCustomFieldValue(epicName)
return '<a href=myURL'+ epic +'>'+ epicNameString +'</a>'
Thank you a lot!