This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
validators [2018/04/20 10:05] root more validators |
validators [2019/02/13 09:10] (current) root added cascading drop down |
||
---|---|---|---|
Line 195: | Line 195: | ||
log.debug(" | log.debug(" | ||
return true | return true | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | === Allow only specific users in project ABC or users in a group " | ||
+ | |||
+ | <code java> | ||
+ | import com.atlassian.jira.component.ComponentAccessor | ||
+ | import com.atlassian.jira.issue.Issue | ||
+ | def groupManager = ComponentAccessor.getGroupManager() | ||
+ | |||
+ | (issue.projectObject.key == ' | ||
+ | |||
+ | |||
+ | </ | ||
+ | |||
+ | === Only allow users in group " | ||
+ | |||
+ | <code java> | ||
+ | import com.atlassian.jira.component.ComponentAccessor | ||
+ | import com.atlassian.jira.issue.Issue | ||
+ | def groupManager = ComponentAccessor.getGroupManager() | ||
+ | |||
+ | groupManager.isUserInGroup(currentUser, | ||
+ | </ | ||
+ | |||
+ | === Check if user is in group " | ||
+ | |||
+ | <code java> | ||
+ | import com.atlassian.jira.component.ComponentAccessor | ||
+ | import com.atlassian.jira.issue.Issue | ||
+ | import com.atlassian.jira.security.roles.ProjectRoleManager | ||
+ | |||
+ | def projectManager = ComponentAccessor.projectManager | ||
+ | def projectRoleManager = ComponentAccessor.getComponent(ProjectRoleManager) | ||
+ | def role = projectRoleManager.getProjectRole(" | ||
+ | |||
+ | def groupManager = ComponentAccessor.getGroupManager() | ||
+ | |||
+ | if (groupManager.isUserInGroup(currentUser, | ||
+ | return true | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | === Check if cascading child drop down is set to " | ||
+ | The following script was found on Atlassian community here: [[https:// | ||
+ | Use the **Custom Validator** for this script-runner script. | ||
+ | <code java> | ||
+ | import com.atlassian.jira.component.ComponentAccessor | ||
+ | import com.atlassian.jira.issue.MutableIssue | ||
+ | import com.opensymphony.workflow.InvalidInputException | ||
+ | |||
+ | def issue = issue as MutableIssue | ||
+ | def cf = ComponentAccessor.customFieldManager.getCustomFieldObjectByName(" | ||
+ | def cfValue = issue.getCustomFieldValue(cf) as HashMap | ||
+ | |||
+ | def parentOption = cfValue.values().getAt(0)? | ||
+ | def childOption = cfValue.values().getAt(1)? | ||
+ | |||
+ | if (!childOption) { | ||
+ | throw new InvalidInputException(" | ||
} | } | ||
</ | </ |