Hi,
I have "Reopen" transition from HOLD and Canceled. I would like to do workflow condition as below.
1. When Status is HOLD and doing the transition REOPEN then PM and Admin role can perform.
2. If the status is Canceled and doing the transition REOPEN then Admin role can perform.
Can anyone tell me how to write condition script to accomplish.
Here I tried but now working.
import com.atlassian.jira.issue.security.IssueSecurityLevelManager
import com.atlassian.jira.issue.security.IssueSecuritySchemeManager
import com.atlassian.jira.issue.Issue;
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.project.Project
import com.atlassian.jira.project.ProjectManager
import com.atlassian.jira.security.roles.ProjectRole
import com.atlassian.jira.security.roles.ProjectRoleManager
import com.atlassian.jira.component.ComponentAccessor
import org.apache.log4j.Category
def Category log = Category.getInstance("com.onresolve.jira.groovy.PostFunction")
log.setLevel(org.apache.log4j.Level.DEBUG)
Issue issue = issue
def changeHistoryManager = ComponentAccessor.getChangeHistoryManager()
def actionId = transientVars["actionId"]
def PrevStat = changeHistoryManager.getChangeItemsForField(issue, "status").getAt(changeHistoryManager.getChangeItemsForField(issue, "status").size() -
1).getFromString()
def currentUser = ComponentAccessor.jiraAuthenticationContext.getLoggedInUser()
def projectManager = ComponentAccessor.getProjectManager()
def projectId = issue.getProjectId()
def project = projectManager.getProjectObj(projectId)
ProjectRoleManager projectRoleManager = (ProjectRoleManager) ComponentAccessor.getComponentOfType(ProjectRoleManager.class)
ProjectRole PrjMgr = projectRoleManager.getProjectRole("Project Manager")
ProjectRole admin = projectRoleManager.getProjectRole("Administrators")
def stat=issue.getStatus().getName()
log.debug " Previous Stat $stat and actionID $actionId"
def holdstatusID="11803"
def canceledID="10202"
if(issue.getStatus().getName() == 'Hold'){
if (projectRoleManager.isUserInProjectRole(currentUser,PrjMgr,project)||projectRoleManager.isUserInProjectRole(currentUser,admin,project)) {
return true;
}
}else if(issue.getStatus().getName()== 'Cancelled'){
if (projectRoleManager.isUserInProjectRole(currentUser,admin,project)) {
log.debug "current user $currentUser"
return true
}
}