Hi,
I use the Script Runner to transition a related issue when an issue is resolved.But the script throws the following error:
2018-08-14 15:01:43,473 ERROR [workflow.ScriptWorkflowFunction]: Script function failed on issue: DCAE-8, actionId: 191, file: <inline script> java.lang.IllegalArgumentException: User null doesn't have permission transition for issue DSW-9. at com.atlassian.jira.workflow.WorkflowTransitionUtilImpl.retrieveActionDescriptorWithPermissionCheck(WorkflowTransitionUtilImpl.java:142) at com.atlassian.jira.workflow.WorkflowTransitionUtilImpl.getActionDescriptor(WorkflowTransitionUtilImpl.java:133) at com.atlassian.jira.workflow.WorkflowTransitionUtilImpl.hasScreen(WorkflowTransitionUtilImpl.java:361) at com.atlassian.jira.workflow.WorkflowTransitionUtilImpl.progress(WorkflowTransitionUtilImpl.java:338) at com.atlassian.jira.workflow.WorkflowTransitionUtil$progress$3.call(Unknown Source) at Script159.run(Script159.groovy:74)
The same script is working fine in other systems but doesnt work in mine.
What am I missing? Can someone help with this.
Thanks in Advance
Did you get the issue resolved? I got the same error:
java.lang.IllegalArgumentException: User null doesn't have permission transition for issue ES2-896.
I have a script dealing with 2 different projects and the user group has the transition issue rights in both of them.
Hi @Tarun Sapra
we created issue type hierarchy using portfolio for Jira to create parent child relationship.
My requirement is once my child gets done then all my above parent in hierarchy gets committed.
Following is my script:
import org.apache.log4j.Category
import com.atlassian.jira.ComponentManager
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.project.Project
import com.atlassian.jira.issue.link.IssueLink
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.bc.issue.IssueService
import com.atlassian.jira.bc.issue.IssueService.TransitionValidationResult
import com.atlassian.crowd.embedded.api.User
import com.atlassian.jira.issue.MutableIssue;
import com.atlassian.jira.issue.CustomFieldManager;
import com.atlassian.jira.issue.fields.CustomField;
import com.atlassian.jira.issue.link.IssueLinkManager
import com.atlassian.jira.issue.link.IssueLinkType
import com.atlassian.jira.issue.link.IssueLinkTypeManager
import com.atlassian.jira.bc.issue.search.SearchService;
import com.atlassian.jira.web.bean.PagerFilter;
import com.atlassian.jira.workflow.WorkflowTransitionUtil;
import com.atlassian.jira.workflow.WorkflowTransitionUtilImpl;
import com.atlassian.jira.util.JiraUtils;
def Category log = Category.getInstance("com.onresolve.jira.groovy.TransitionToDevComplete")
def currentUserObj = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
//def issueManager = ComponentAccessor.getIssueManager()
def linkMgr = ComponentAccessor.getIssueLinkManager()
log.info ("Current issue ID: " + issue.id)
def customFieldManager = ComponentAccessor.getCustomFieldManager();
def parentLink = customFieldManager.getCustomFieldObjectByName("Parent Link");
log.info("parent link "+ parentLink)
def defCustomFieldValue = issue.getCustomFieldValue(parentLink);
String customFieldValue = issue.getCustomFieldValue(parentLink);
//String grandParentFieldValue = issue.getCustomFieldValue(customFieldValueDef);
//def parentIssue = (Issue) customFieldValue;
def flagStatus = true
def flagForCap = true
def flagForInit=true
if(customFieldValue)
{
def issueManager = ComponentAccessor.getIssueManager();
def project = issueManager.getIssueByCurrentKey(customFieldValue);
def jqlSearch = "issuekey in childIssuesOf(" + customFieldValue + ")";
log.info('jqlSearch: ' + jqlSearch)
getFilterResult (jqlSearch).each{Issue issue1 ->
log.info(issue1.getKey() + " " + issue1.getStatus().name + " " + issue1.getStatus().getName());
if(issue1.getStatus().name != "Committed") {
log.info("changing status to false: Before Flag Value"+flagStatus)
flagStatus = false
log.info("changing status to false: After Flag Value"+flagStatus)
}
}
String currentUser = ComponentAccessor.jiraAuthenticationContext.loggedInUser.name;
WorkflowTransitionUtil workflowTransitionUtil = (WorkflowTransitionUtil) JiraUtils.loadComponent(WorkflowTransitionUtilImpl.class);
if(flagStatus == true){
log.info("for true status "+flagStatus)
workflowTransitionUtil.setIssue(project);
workflowTransitionUtil.setUserkey(currentUser);
workflowTransitionUtil.setAction(131);
workflowTransitionUtil.validate();
workflowTransitionUtil.progress();
}else {
log.info("for false status "+flagStatus)
workflowTransitionUtil.setIssue(project);
workflowTransitionUtil.setUserkey(currentUser);
workflowTransitionUtil.setAction(201);
workflowTransitionUtil.validate();
workflowTransitionUtil.progress();
}
//issuekey in parentIssuesOf("DES-2") AND issuetype = Capability_design
def jqlSearchGrandParentCap = "issuekey in parentIssuesOf(" + customFieldValue + ") AND issuetype = Capability_design";
log.info('jqlSearchGrandParent: ' + jqlSearchGrandParentCap)
getFilterResult (jqlSearchGrandParentCap).each{Issue issue1 ->
log.info(issue1.getKey() + " " + issue1.getStatus().name + " " + issue1.getStatus().getName());
String capKey = issue1.getKey()
def projectCap = issueManager.getIssueByCurrentKey(capKey);
def jqlSearchCapabilitiesFromGrandParent = "issuekey in childIssuesOf(" + issue1.getKey() + ")";
log.info('jqlSearchGrandParent: ' + jqlSearchGrandParentCap)
getFilterResult (jqlSearchCapabilitiesFromGrandParent).each{Issue issueCap ->
log.info(issueCap.getKey() + " " + issueCap.getStatus().name + " " + issueCap.getStatus().getName());
//Checking if the parent capability of feature is equal to the capability fetched here (through initiative)
if(customFieldValue != issueCap.getKey() && issueCap.getStatus().name != "Committed") {
log.info("changing status to false: Before flagForCap"+flagForCap)
flagForCap = false
log.info("changing status to false: After flagForCap"+flagForCap)
}
}
if(flagForCap == true){
log.info("flagForCap for true status "+flagForCap)
workflowTransitionUtil.setIssue(projectCap);
workflowTransitionUtil.setUserkey(currentUser);
workflowTransitionUtil.setAction(131);
workflowTransitionUtil.validate();
workflowTransitionUtil.progress();
}else {
log.info("flagForCap for false status "+flagForCap)
workflowTransitionUtil.setIssue(projectCap);
workflowTransitionUtil.setUserkey(currentUser);
workflowTransitionUtil.setAction(101);
workflowTransitionUtil.validate();
workflowTransitionUtil.progress();
}
}
//issuekey in parentIssuesOf("DES-1") AND issuetype = Initiative
def jqlSearchGreatGrandParentInit = "issuekey in parentIssuesOf(" + customFieldValue + ") AND issuetype = Initiative";
log.info('jqlSearchGrandParent: ' + jqlSearchGreatGrandParentInit)
getFilterResult (jqlSearchGreatGrandParentInit).each{Issue issue1 ->
log.info(issue1.getKey() + " " + issue1.getStatus().name + " " + issue1.getStatus().getName());
String initKey = issue1.getKey()
def projectInit = issueManager.getIssueByCurrentKey(initKey);
def jqlSearchCapabilitiesFromGrandParent = "issuekey in childIssuesOf(" + issue1.getKey() + ")";
log.info('jqlSearchGrandParent: ' + jqlSearchGreatGrandParentInit)
getFilterResult (jqlSearchCapabilitiesFromGrandParent).each{Issue issueCap ->
log.info(issueCap.getKey() + " " + issueCap.getStatus().name + " " + issueCap.getStatus().getName());
//Checking if the parent capability of feature is equal to the capability fetched here (through initiative)
if(customFieldValue != issueCap.getKey() && issueCap.getStatus().name != "Committed") {
log.info("changing status to false: Before flagForInit"+flagForInit)
flagForInit = false
log.info("changing status to false: After flagForInit"+flagForInit)
}
}
if(flagForInit == true){
log.info("flagForInit for true status "+flagForInit)
workflowTransitionUtil.setIssue(projectInit);
workflowTransitionUtil.setUserkey(currentUser);
workflowTransitionUtil.setAction(131);
workflowTransitionUtil.validate();
workflowTransitionUtil.progress();
}else {
log.info("flagForInit for false status "+flagForInit)
workflowTransitionUtil.setIssue(projectInit);
workflowTransitionUtil.setUserkey(currentUser);
workflowTransitionUtil.setAction(101);
workflowTransitionUtil.validate();
workflowTransitionUtil.progress();
}
}
}
List<Issue> getFilterResult(String jqlSearch)
{
def user = ComponentAccessor.jiraAuthenticationContext.getLoggedInUser()
SearchService searchService = ComponentAccessor.getComponent(SearchService.class)
SearchService.ParseResult parseResult = searchService.parseQuery(user, jqlSearch)
List<Issue> issues = null
if (parseResult.isValid()) {
def searchResult = searchService.search(user, parseResult.getQuery(), PagerFilter.getUnlimitedFilter())
issues = searchResult.issues
}
else {
return null;
}
return issues
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Tarun Sapra
I checked the transition issue permission, as shown in below screenshot .
it shows application access to 'any logged user' for all the projects
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Can you share the script and script configuration snapshot
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello @Ghazal Kumari
Is the related issue in the same project? Because from the error it seems that the related issue is in another project and the user resolving the current issue doesn't have "transition issue" permission in the linked issue's project.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The related issue is in different project, we tried the same thing in my colleague's system where the transition is in different project and it works fine there.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello @Ghazal Kumari
It depends on the user executing the transition as his user account is taken into consideration, does you account has transition issues permission in all impacted projects? Or is it that in the script you are using an "bot" account to execute the transition instead of the account of the current user.
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.