Post Function clone issue and set assignee from single select list

Henry Lin April 7, 2021

hi Community, 

I've been stuck on following task for some time now; could anyone please point me to the right direction? thanks!

 

System info:

JIRA Data Center 8.5.6

Adaptive Scriptrunner: 6.22.0

 

Objective:

Clone an issue from ProjectA to ProjectB, upon closing the issue from ProjectA, a single select list (None, User 1, User 2, User 3) shows up on the close screen; if None is selected, nothing happens; otherwise, if User 1 or User2 or User3 is selected, the assignee on the cloned/new issue (projectB) will be the selected user (from single select list)  

 

Current Status:

Cloning is working; however assignee in new issue (projectB) is not functional

 

Post Function:

Condition:

cfValues['Design QA Owner']?.value

 

Additional issue actions:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.user.util.UserManager
import com.atlassian.jira.event.type.EventDispatchOption
import com.onresolve.jira.groovy.user.FieldBehaviours
import groovy.transform.BaseScript

UserManager userMgr = ComponentAccessor.getUserManager()
IssueManager issueMgr = ComponentAccessor.getIssueManager()
ApplicationUser currUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()

def designQAOwner = ComponentAccessor.getCustomFieldManager().getCustomFieldObject("customfield_12818")
def selectedValue = designQAOwner.getValue(issue) as String

def user

if (selectedValue == "User 1"){
user = userMgr.getUserByName("test_user1")
}

else if (selectedValue == "User 2"){
user = userMgr.getUserByName("test_user2")
}

else if (selectedValue == "User 3"){
user = userMgr.getUserByName("test_user3")
}

issue.setAssignee(user)

 

Logs: 
2021-04-07 15:11:01,809 DEBUG [utils.ConditionUtils]: Condition did not return a boolean, coercing to true
2021-04-07 15:11:01,809 DEBUG [utils.AbstractCloneIssue]: System fields to copy: [description, summary]
2021-04-07 15:11:01,816 DEBUG [utils.AbstractCloneIssue]: Custom fields to copy: []
2021-04-07 15:11:01,885 DEBUG [utils.AbstractCloneIssue]: Run As User hlin(hlin)
2021-04-07 15:11:01,917 ERROR [recordparser.RecordParserUtils]: commentId is null


regards,

Henry

2 answers

1 accepted

2 votes
Answer accepted
John Chin
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.
April 7, 2021

Hi @Henry Lin ,

From this line, you are trying to retrieve the select list value from the clone issue:

def selectedValue = designQAOwner.getValue(issue) as String

To get the original issue object information, please use sourceIssue (instead of issue):

def selectedValue = designQAOwner.getValue(sourceIssue) as String

This same apply on getting the reporter and assignee user of the original issue:

sourceIssue.assignee

sourceIssue.reporter

To add the those users, you can use refer to the example of the community link here.

I hope this helps.

Henry Lin April 8, 2021

@John Chin , thank you so much! your suggestions worked!

 

regards, 

Henry

0 votes
Henry Lin April 7, 2021

hi @Martin Bayer _MoroSystems_ s_r_o__ , @Nic Brough -Adaptavist- 

@Lee Wonnacott, could you please take a look at this request? appreciate in advance!

 

regards, 

Henry

Henry Lin April 7, 2021

also, how can get the reporter and the assignee from the original issue as the watchers in new/cloned issue? 

Suggest an answer

Log in or Sign up to answer