Forums

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

Set Security Level as per component

Rakesh Jajper March 29, 2022

Hi Everyone,

 

I am trying to set security level as per component selected on ticket using behavior settings in scriptrunner.

I want to set once ticket created as per workflow transition then if they update ticket or change component it should reflect security level immidiately on ticket.

here what I am using but another question is how to get security ID's, I think we can't use security level values.

import com.atlassian.jira.issue.Issue
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.type.EventDispatchOption
def component = getFieldById("components")
def componentV = component.getValue()
 
 
if (componentV.toString().contains("NTD")) {
    issue.setSecurityLevelId(10000);
    }
else {
    issue.setSecurityLevelId(10001);
}

1 answer

0 votes
Benjamin
Community Champion
March 30, 2022

HI @Rakesh Jajper ,

 

I'm not sure about security level ID but most objects will show their ID in the URL if click on it and hover over it. This works with projects, custom fields, and etc.

 

-Ben

Rakesh Jajper March 30, 2022

Thanks Benjamin

Yes that helps will be partial answer to my question

Can you please check if my code is good if I attach to listener or behavior, as currently its not working what it is.

Look like the way I am reading component value is not correct, can you please help here.

Benjamin
Community Champion
March 30, 2022

Hi @Rakesh Jajper 

 

This should be attach to behaviors base on what you are trying to accomplish. I'm not familiar with the class you are using. If you don't get a response here, I would recommend checking script runner documentation to get some relatively close examples or post your questions in the apps and integration area. You may run into some scripting or ScriptRunner members there.

 

-Ben

Suggest an answer

Log in or Sign up to answer