Hello,
I am trying to set criteria on when a transition is allowed in a certain workflow. Its based on two conditions -
1) Custom Select Field value
2) user needs to be part of a certain group
The following is a "Custom Script Condition" I added on the transition condition.
There are no syntax errors in the following but I dont see the expected behavior -
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.user.ApplicationUser
import com.opensymphony.workflow.WorkflowContext
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.Issue
def issueManager = ComponentAccessor.getIssueManager()
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def DBCCTypeCf = customFieldManager.getCustomFieldObject("customfield_12323")
def DBCCType = issue.getCustomFieldValue(DBCCTypeCf)
passesCondition=false
def groupManager = ComponentAccessor.getGroupManager()
def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
if (DBCCType == "Data Update") {
if (groupManager.isUserInGroup(currentUser, "Team DBCC Approver")) {
passesCondition=true
return
}
}
I have a suspicion that its to do with this check -
if (DBCCType == "Data Update") {
This doesnt work for Issues where this criteria is true.
Thanks,
Venkat
I assume that DBCCType is selected list type. Since here is a refactored code:
import com.atlassian.jira.component.ComponentAccessor import com.atlassian.jira.issue.customfields.option.Option Option DBCCType = (Option) issue.getCustomFieldValue(ComponentAccessor.getCustomFieldManager().getCustomFieldObject("customfield_12323")) passesCondition = false if (DBCCType.getValue() == "Data Update") { def currentUser = ComponentAccessor.getJiraAuthenticationContext().getUser().directoryUser if (ComponentAccessor.getGroupManager().isUserInGroup(currentUser, "Team DBCC Approver")) { passesCondition=true return } }
Works great! I guess it was the type casting that I was missing.
I appreciate your help!
Thanks.
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.