This is what I am trying to accomplish: I have timecard charge numbers as a custom field define for all our epics. I am using arsenal dataplane to create a report for all team members that show the time they logged on tasks and subtasks. I would like to show in that report the charge code for the epic associated with the task. If you didn't follow here's another explanation of what I am trying to do: simply show the value from an epic custom field in a report that shows task information.
I think I can do this with scriptrunner custom field for a task that finds the parent epic and reads the charge number value. I would then have that information in a custom field associated with task that I can use for reports. I have created a custom field in scriptrunner for the task but can't figure out the script. Any help on writing the script would be greatly appreciated. If you don't use scriptrunner but know how to do this from Java API plugin I would love to see that code because that might be good enough for showing me how to do it. Thanks!
The code would be like this
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 customFieldManager = ComponentAccessor.getCustomFieldManager();
CustomField epicLink = customFieldManager.getCustomFieldObjectByName('Epic Link');
Issue epic = issue.getCustomFieldValue(epicLink) as Issue;
CustomField cs = customFieldManager.getCustomFieldObjectByName("customFieldName");
return epic.getCustomFieldValue(cs)
This worked beautifully! Thank you. Except. This worked for just the tasks. Is there some code that could be added such that if this is a subtask that it moves to the task and then finds the custom field.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Figured out something that works for subtasks and tasks. Again, thanks for help! See code below:
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 customFieldManager = ComponentAccessor.getCustomFieldManager();
CustomField epicLink = customFieldManager.getCustomFieldObjectByName('Epic Link');
if (issue.isSubTask()){
issue = issue.getParentObject();
}
Issue epic = issue.getCustomFieldValue(epicLink) as Issue;
CustomField cs = customFieldManager.getCustomFieldObjectByName("Charge Code");
return epic.getCustomFieldValue(cs)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.