Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How to validate Security level and Reporter field using scriptrunner

Akhil_vs
Contributor
November 12, 2018

Hello Team,

I have a requirement where if security level is set as "Customer Request" then the reporter should not be from the group "ABC_Internal"

 

I have to set a custom validator script to achieve this

Can the adaptivist please help me in achieving this .?

1 answer

1 accepted

0 votes
Answer accepted
Neta Elyakim
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 12, 2018

You need to check it in the script according to your security level Id.

See this script:

import com.atlassian.jira.component.ComponentAccessor
import com.opensymphony.workflow.InvalidInputException

def groupManager = ComponentAccessor.getGroupManager()
def customFieldManager = ComponentAccessor.getCustomFieldManager()

long issueSecurityLevelId = issue.getSecurityLevelId()
long customerRequestSecurityLevelId = 10000 //change here your Customer Request Security Level Id

if (issueSecurityLevelId == customerRequestSecurityLevelId) {
if(groupManager.isUserInGroup(issue.getReporter(), "ABC_Internal")) {
invalidInputException = new InvalidInputException("if security level is set as 'Customer Request' then the reporter should not be from the group 'ABC_Internal'");
return null
}

In order to find and modify 'customerRequestSecurityId' param, go to your Issue Security Schemes > edit the scheme (Security Levels) > edit the security level > in the URL you have 'levelId' param- this is the security level id.

Akhil_vs
Contributor
November 13, 2018

@Neta Elyakim Thank you very much . This script meets my requirements.

Like Neta Elyakim likes this
ezgiiklcrsln March 14, 2019

Hi, 

I have one project and one security level scheme. The security level scheme includes two security levels such as Level 1 and Level 2. Level 1 is arranged with "group_X" and Level 2 arranged with "gorup_Y", In addition. 

I need a validator for project workflow. If the reporter is not in security level groups (group_X or group_Y), the reporter  will give an error message and the reporter cannot create the issue. 

Can you help me ? 

Suggest an answer

Log in or Sign up to answer