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

ScriptRunner for JIRA Cloud - condition for sending notification post function

I have a ScriptRunner post function that sends out a notification email, but I'm trying to give a condition on a checkbox custom field.  There are 3 options to the custom field, but when I use issue.fields.customfield_10133 == "Option1" it is always returning false.

To validate that I am using a valid option, I ran the following in Script Console to validate the value on an issue where it was set to "Option1"

def issueKey = 'KEY-8000'

def customFieldName = 'customfield_10133'

def result = get("/rest/api/2/issue/${​​​​​​​issueKey}​​​​​​​?fields=${​​​​​​​customFieldName}​​​​​​​")

.header('Content-Type', 'application/json')

.asObject(Map)

if (result.status == 200) {​​​​​​​     return result.body.fields[customFieldName]      }​​​​​​​ else {​​​​​​​     return "Error retrieving issue ${​​​​​​​result}​​​​​​​"      }​​​​​​​

 

Should I use the ID number associated with the option, or is there another way to state my condition?

 

1 answer

1 accepted

0 votes
Answer accepted

Hi Matt,

Thank you for your question.

I can confirm that checkbox fields use a List data structure which means you must get all values and check if they match the value you want to have as the selected value in order to test this in a workflow post function condition.

I can confirm I have created an example of how to do this here which you can use as a reference guide to help create the condition which you require.

I hope this information helps.

Regards,

Kristian

@Kristian Walker _Adaptavist_  Thank you for the information.  I placed this suggested correction in my post function and now I am getting an error: [Static Type Checking] - No such property: Value for class: java.lang.object @ line 1, Column 51

 

I'm new to Groovy - do I need to import a different library for this to work?  This is for JIRA cloud.

Hi Matt,

This is just a static type checking warning where the compiler does not understand the code as described here and will not stop the code from working.

This means you should be able to save and run the code and it will work as expected.

Regards,

Kristian

Like Matt Noe likes this

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