Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How to set issue security level depending on custom field condition?

Current situation:

  • ScriptRunner Post function 'Clones an issue, and links' used for cloning an issue from project X to project Y
  • In project Y the Security Level is automatically set to 'Internal'  (by using a the post function 'Set issue security level depending on provided condition" on the create transition)

Wish

  • Set the Security Level based on a condition:
    • IF custom field in original issue in project X "'Set Reported Issue Public?" = "Yes", THEN set Security level to "Public"
    • IF custom field in original issue in project X "'Set Reported Issue Public?" = "No", THEN set Security level to "Internal"

Current implementation

I've the following condition

issueLinkManager.getOutwardLinks(issue.id)*.destinationObject!(cfValues['Set Reported Issue Public?']?.value == "No"

However, I'm getting an error:

Script270.groovy: 1: expecting EOF, found '!' @ line 1, column 62.
   s(issue.id)*.destinationObject!(cfValues

Not sure how to implement the condition. 

1 answer

1 accepted

0 votes
Answer accepted

Hey @Berry Kersten, in this case, if you're accessing a custom field value from your project X within a post function in your project Y, the issue in Y would have an inward link to X. I would slightly change your condition code to something like:

issueLinkManager.getInwardLinks(issue.id)*.destinationObject*.getCustomFieldValue(customFieldManager.getCustomFieldObject("customfield_<id>")).equals("No")

Even fixing it, I believe you will probably find some challenges to make it work. If I'm not mistaken, in the create transition, you will not have access to the linked issue object before it gets indexed.

Perhaps, as an alternative and way less painful, through the Clones an issue, and links post function in project X, in Additional issue actions, you can add the following snippet

def cf = customFieldManager.getCustomFieldObjects(sourceIssue).find {it.name == 'Set Reported Issue Public?'}

if (sourceIssue.getCustomFieldValue(cf).toString().equals("No")) {
issue.setSecurityLevelId(<id>)
}

I hope it helps,
IL.

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Marketplace Apps & Integrations

Learn how to request and manage app requests in the Marketplace

G’day everyone! Super exciting news coming from the Marketplace. We have now fully rolled out the ability for end-users to submit app requests to admins directly from within the product! No longer ...

43 views 1 5
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you