Hello.
In my case, it is proceeded when jira issue is created.
For example
Jira issue Field
1#Custom_Field : User Picker (single user) << Field Required
2#Custom_Field : User Picker (single user)
Q1.
If the 2#Custom_Field value is included, Change Assignee(2#Custom_Field) and
Go to Jira's specific status
Q2.
If the 2#Custom_Field value is Not included, Change Assignee(1#Custom_Field)
I don't know how to implement it using Script-Runner.
Can I help you?
Thank U . EveryOne
Hi @장부현
For your requirement, I suggest upgrading your ScriptRunner to the latest release, i.e. 7.11.0 and trying to use the HAPI features.
Below is a sample working code for your reference:-
def userPicker1 = issue.getCustomFieldValue('Sample User Picker 1')
def userPicker2 = issue.getCustomFieldValue('Sample User Picker 2')
issue.set {
setAssignee(userPicker1.name)
if (userPicker1 && userPicker2) {
setAssignee(userPicker2.name)
}
}
Please note that the sample code above is not 100% exact to your environment.
Below are the screenshots for the Post-Function configuration:-
1. Go to the Workflow Diagram and select the Create transition. Once the property dialog appears, click on the Post-Function as shown in the screenshot below:-
2. In the Post-Function options, select the Custom script post-function [ScriptRunner] option as shown below:-
3. Finally, once you are on the Custom script post-function page, you can add the sample code I provided above. Please ensure that you make the required changes.
One point, please ensure that the Post-Function is added to the very top of the Create transition as shown in the screenshot below:-
I hope this help to solve your question. :-)
Thank you and Kind regards,
Ram
Hi @장부현
Has your question been answered?
If yes, please accept the solution provided.
Thank you and Kind regards,
Ram
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi there!
Before going into scriptrunner, do you have automation on your instance because with that I think you would not have to write a single line of code.
That being said, I have a similar script that really should get you on the way:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.fields.CustomField
IssueManager issueManager = ComponentAccessor.getIssueManager()
MutableIssue editIssue = issue
def userpickerFieldId = 13401L
CustomField userPickerField = ComponentAccessor.getCustomFieldManager().getCustomFieldObject(userpickerFieldId)
def user = editIssue.getCustomFieldValue(userPickerField)
def updateUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
if (user == null) {
return false
}
editIssue.setAssignee(user)
try {
issueManager.updateIssue(updateUser, editIssue, EventDispatchOption.ISSUE_UPDATED, true)
} catch(Exception e) {
log.error("Error setting assignee $user.username on issue $editIssue.key")
}
This script:
With some change you can get it to work for your case. When finished this should be in a postfunction of the Create transition.
Hope this helps!
Jeroen
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.