Hello.
I've created a post script function in a transition for automated assignment.
The script is post function is followed by the standard store and indexing functions.
This works sometimes fine, sometimes not.
First the script:
.......................
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.customfields.option.LazyLoadedOption
def versionManager = ComponentAccessor.getVersionManager()
def issueManager = ComponentAccessor.getIssueManager()
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def Betreft = issue.getCustomFieldValue(ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Vraagcategorie")) as Map
def Hoofdcategorie = Betreft.get(null) as LazyLoadedOption
def Subcategorie = Betreft.get("1") as LazyLoadedOption
def Regio = issue.getCustomFieldValue(ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("(Informatie) Regio")) as LazyLoadedOption
def Afwijking = issue.getCustomFieldValue(ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Melding afwijking")) as LazyLoadedOption
if (Afwijking.getValue()=="X" ) {
issue.setAssigneeId("userx@gmail.com")
} else if (Subcategorie.getValue()=="Y" ) {
issue.setAssigneeId("usery@gmail.com")
} else if (Subcategorie.getValue()=="Z" && Regio==null ) {
issue.setAssigneeId("userz0@gmail.com")
} else if (Subcategorie.getValue()=="Z" && Regio.getValue()=="1" ) {
issue.setAssigneeId("userz1@gmail.com")
} else if (Subcategorie.getValue()=="Z" && Regio.getValue()=="2" ) {
issue.setAssigneeId("userz2@gmail.com")
} else if (Subcategorie.getValue()=="Z" && Regio.getValue()=="3" ) {
issue.setAssigneeId("userz3@gmail.com")
} else if (Subcategorie.getValue()=="Z" && Regio.getValue()=="4" ) {
issue.setAssigneeId("userz4@gmail.com")
} else {
issue.setAssigneeId("userA@gmail.com")
}
......................
The strange thing is that with userx and usery the assignee is set to the user asked.
For the other users, the assignee is filled but seen as not set.
When I open the issue, the user seems set but the picto is a question.
When entering the name the assignment is set.
I've no idea whats the difference between the users.
All are assignable.
All have logged in once.
All have the same permissions.
I've no clue
Anyone?
assignmentproblem.jpg
Hi Arco,
I would suggest to use
def user = ComponentAccessor.getUserManager().getUserByName("username") issue.setAssignee(user)
instead of assigneeId.
Second thing, you should make sure that the post function is the first one or at least before the "Update change history for an issue and store the issue in the database." step.
regards, Thanos
Yesss! That did the trick. The first part, defining 'user'.
Still don't understand why setAssigneeID works inconsequent, but thats not my problem any more!
Thank you very much! Made my day!
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.