Forums

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

ScriptRunner: Set reporter of sub-task to the assignee of the parent task

Deleted user February 20, 2019

Hello

I have a behaviour which should set the reporter of a sub-task to the assignee of the parent task.

Here's an extract of my script.

FormField parent = getFieldById("parentIssueId")
Long parentIssueId = parent.getFormValue() as Long

def parentIssue = issueManager.getIssueObject(parentIssueId)
def parentIssueAssignee = parentIssue.assigneeId

def subTaskReporter = getFieldById(REPORTER)

subTaskReporter.setFormValue(parentIssueAssignee)
subTaskReporter.setReadOnly(true)

However, the reporter remains the same as the current user.

grafik.png

When I hardcode the reporter to for example "svc_jirabot", it works.

subTaskReporter.setFormValue("svc_jirabot")

grafik.png

The assignee ID gets retrieved successfully so I don't know what's the issue here. Here's an extract of my debug log

[c.o.j.groovy.user.FieldBehaviours] --------------------This is to test Behaviours Logging----------------
[c.o.j.groovy.user.FieldBehaviours] svc_jirabot

Any Ideas?

BR
Marius

 

 

1 answer

0 votes
Tarun Sapra
Community Champion
February 20, 2019

Hello @[deleted] 

Instead of using Behaviour for this, why don't you implement this change in the post-function of the create transition of the sub-task.

Tarun Sapra
Community Champion
February 20, 2019

The kind of requirement which you have is easier to implement using the backend API instead of behaviour.

Deleted user February 20, 2019

I would like the user to be able to see what is being set right on the create issue screen. It enhances usability in my opinion.

I have never worked with the backend API and as I'm really close to getting it, I don't think it would be the easier aproach. Scriptrunner ist just bugging out here idk

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events