Set Security Level based customfield post-function

Dante Labate July 26, 2018

Can anybody help me?

I guess I'm commenting some silly mistake

I have more than 60 security level created (one for each cost center)

I'm trying to create a post-function script that will fill the security level according to the cost center informed.

But I can not understand why the issue.setSecurityLevelId (10501) gets highlighted saying "Can not find matching method"

 

import com.atlassian.jira.component.ComponentAccessor


def customFieldManager = ComponentAccessor.getCustomFieldManager()

def CC = customFieldManager.getCustomFieldObject("customfield_16029")
def CC_value = issue.getCustomFieldValue(CC).toString()

if (CC_value == 'XYZ')
{
issue.setSecurityLevelId(10501)
}

 PrtScr capture.jpg

1 answer

1 accepted

1 vote
Answer accepted
Tansu Akdeniz
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 26, 2018

Hi @Dante Labate,

If you have Script Runner, what about doing in that way; 

  • Add post-function -> Script post-function
  • Select "Set issue security level depending on provided condition"
  • Add condition and choose the security level

image.png

Dante Labate August 6, 2018

Hi @Tansu Akdeniz

sorry for the delay to reply..

I can not do the way you indicated because the security level will be based on the cost center of the person who is opening the issue.

so I have to do some checks on the post-function to know what the correct cost center is.

if it were to do the form suggested, it would have to have several post-function validating whether or not it is in that cost center (we have 70 different cost center).

My code works, I was just curious why the red mark (as if it was wrong).

Tansu Akdeniz
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 7, 2018

Ahh got it @Dante Labate.  There is nothing wrong with your code.

The reason for red mark is; script doesn't recognize the issue so it doesn't find matching method for issue.setSecurityLevelId(). (but gets issue object in post-function as expected) 

Ex; if you add the following line at the beginning, you will not see that error. But do not of course, it just for one example issue :)

def issue = ComponentAccessor.getIssueManager().getIssueObject("ABC-1"); 
Dante Labate August 8, 2018

Ahhh .. that makes perfect sense ..

Thank you for answering my question.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events