Hi,
i'm using ScriptRunner 4.3.12 and JIRA 7.1.9.
I'm trying to close all subtasks of an issue by using a custom "Post Function" Script in the parent's workflow transition.
There are two Workflow, one for the "Parent" an one for the "Subtasks".
The script looks as follows:
import com.atlassian.jira.component.ComponentAccessor def transitionId = 81 // abnehmen def issueService = ComponentAccessor.issueService def user = ComponentAccessor.jiraAuthenticationContext.loggedInUser issue.subTaskObjects.each { def issueInputParameters = issueService.newIssueInputParameters() issueInputParameters.with { setResolutionId("10000") // resolution of "Fertig" setComment("*Abnahme* durch erfolgreiche Abnahme des Oberauftrags.") setSkipScreenCheck(true) } def validationResult = issueService.validateTransition(user, it.id, transitionId, issueInputParameters) if (validationResult.isValid()) { def issueResult = issueService.transition(user, validationResult) if (! issueResult.isValid()) { log.warn("Failed to transition subtask ${it.key}, errors: ${issueResult.errorCollection}") } } else { log.warn("Could not transition subtask ${it.key}, errors: ${validationResult.errorCollection}") } }
The transition in the subtask workflow is "abnehmen" with id 81. And the "Post Function" are
(Since our JIRA is set to German, I've added some loosely translations)
When the script get's triggered by the parent workflow's transition, the script itself run's without an error.
But the conditon to validate the "validationResult" fails, because of the following error:
2016-10-25 12:23:48,585 WARN [workflow.ScriptWorkflowFunction]: Could not transition subtask AES-174, errors: Errors: {} Error Messages: [Sie sind nicht berechtigt, Vorgänge zuzuweisen.]
(engl. "You're not allowed to assign issues")
And well, that's right. The user has no permission to assign an issue. But I don't understand why this should be required?
I don't want to give him this permission.
All i try to do is "programatically" invoke the "abnehmen" transition of each subtask - which works perfectly fine if the user clicks manually on this button.
Whats wrong there?
Best regards
Peter
I think there are three security context to investigate:
User who is used inside the script (In my case: ComponentAccessor.jiraAuthenticationContext.loggedInUser)
As you can do it manually, but not via script, it implies that the script is running with different permissions than you have in the UI. Is it the same user?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I've added the "setRetainExistingValuesWhenParameterNotProvided(
true
)"
and another log output message (log.warn("Try to transition $it.key ($it.id)")
) just to verify the Issue key and ID.
The error message is still the same :-/
2016-10-31 17:12:24,080 WARN [workflow.ScriptWorkflowFunction]: Try to transition AES-227 (13632) 2016-10-31 17:12:24,127 WARN [workflow.ScriptWorkflowFunction]: Could not transition subtask AES-227, errors: Errors: {} Error Messages: [Sie sind nicht berechtigt, Vorgänge zuzuweisen.] 2016-10-31 17:12:24,127 WARN [workflow.ScriptWorkflowFunction]: Try to transition AES-228 (13633) 2016-10-31 17:12:24,158 WARN [workflow.ScriptWorkflowFunction]: Could not transition subtask AES-228, errors: Errors: {} Error Messages: [Sie sind nicht berechtigt, Vorgänge zuzuweisen.]
Translation: "Sie sind nicht berechtigt, Vorgänge zuzuweisen."
>> "You're not allowed to assign issues"
Also, i've tried to invoke the transition on the AES-227
Issue (first Subtask) manually, which works perfectly.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Could you replace the issueInputParameters with:
issueInputParameters.with { setResolutionId("10000") // resolution of "Fertig" setComment("*Abnahme* durch erfolgreiche Abnahme des Oberauftrags.") setSkipScreenCheck(true) setRetainExistingValuesWhenParameterNotProvided(true) }
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I'd want to check the validators and conditions on the transitions as well. Do they block assignment?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
There are the following conditions (OR'd)
Nur Benutzer welche zu folgenden Rollen gehören können diesen übergang ausführen: Führungskraft AE
(Only user with the following Role can perform this transition: "Führungskraft AE")
Aktueller Benutzer muss im Feld Abnahme sein.
(Current User must be in custom Field "Abnahme")
and one validator:
Simple Script Validator
issue.parentObject.status.name == 'Abgenommen'
the following post function (as mentioned above)
no trigger.
The user who triggers the transition has the role "Führungskraft AE".
Is there maybe a problem caused by the different workflows for the Task and Subtask?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Is that the validators and conditions for the sub-task workflow?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yes, its for the transition 81 named "abnehmen" of the sub-task workflow.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ok, that's good information. The next question is can the user executing the post-function assign the sub-tasks when they look at them in the UI? And can they perform the transition manually?
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.
Double checked the post functions. There is nothing that changes the assingee, just the six steps already mentioned above.
In case there were such a "post function", the manual way should also not work, should it?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Try to investigate transition wuth id = 81 for any postfunction which change assignee.
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.