Hi everyone,
Hope this question finds you well.
On create screen, I want to be able to determine who is the assignee based on the chosen value of a drop down custom field. (using Behaviour Script)
I looked here but the answers given seem to point after the issue has been created.
And others that I looked also most of them handle after the issue has been created,
Here is my code:
void setAssignee(){
FormField ffAssignee = getFieldByName("Assignee")
String value = getFieldById(customfield_id).getFormValue()
if (value in HERE){
ffAssignee.setAssigneeId("name.lastname")
} else if (value in THERE){
ffAssignee.setAssigneeId("name.lastname")
}
}
I tried this as suggested in here (given in link above as answer), but still could not get it to work
void setAssignee(){
FormField ffAssignee = getFieldByName("Assignee")
String value = getFieldById(customfield_id).getFormValue()
if (value in HERE){
ffAssignee.setAssignee(ComponentAccessor.getUserManager().getUserByKey("name.lastname"))
} else if (value in THERE){
ffAssignee.setAssignee(ComponentAccessor.getUserManager().getUserByKey("name.lastname"))
}
}
Any pointers would be helpful!
Here is the working code. just need to change the field pickup to getFieldChanged()
void setAssignee(){
FormField ffAssignee = getFieldByName("Assignee")
FormField desiredField = getFieldById(getFieldChanged())
String value = desiredField.getFormValue()
if (value in HERE){
ffAssignee.setFormValue("name.lastname")
} else if (value in THERE){
ffAssignee.setFormValue("name.lastname")
}
}
Hope this helps anyone who is facing same issue.
Stay safe everyone
Please make an updateIssue after setting the value and see whether change is reflected. Refer to the function in https://docs.atlassian.com/software/jira/docs/api/8.0.1/index.html?com/atlassian/jira/issue/IssueManager.html
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Fazila Ashraf , yes the change is reflected. I tested on another field without the need to use the updateIssue.
On create screen, we want to show the user the Assignee (system field) for the value (a dropdown) before the issue gets created, not after.
Sorry the updateIssue function does not seem to help here.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.