Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

ScriptRunner post function: Create sub-task; set reporter using custom field value of parent

Gavin Minnis June 7, 2018

I am using the ScriptRunner post function "Create Sub-Task," and I am trying to find a way to set the Reporter of the sub-task based on a custom value field called Cost Center Manager. This is a user-picker field type.

My current script is as follows:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.Issue

def value = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Cost Center Manager").getValue(issue)

issue.summary = issue.issueType.name + ' Tasks: ' + sourceIssue.summary
issue.description = 'In the DETAILS section above, please review the list of requested devices, applications, and systems for ' + sourceIssue.summary + '. Once approved, advance through the workflow as you implement the requested changes, verify the changes, and resolve the issue.'
issue.reporterId = value

checkLink = {link -> false};

1 answer

1 accepted

2 votes
Answer accepted
Mark Markov
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 7, 2018

Hello @Gavin Minnis

There is an error in your code. When you get customfieldvalue, you get it from subtask issue, where it is null.
You must get it from parent:

def value = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Cost Center Manager").getValue(sourceIssue)
Gavin Minnis June 7, 2018

@Mark Markov: That was the problem! The script works perfectly now. Thank you.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events