Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Post Function clone issue and set assignee from single select list

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

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.

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

 

regards, 

Henry

hi @Martin Bayer _MoroSystems_ s_r_o__ , @Nic Brough _Adaptavist_ 

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

 

regards, 

Henry

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
TAGS

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you