Test if Component/s is empty with Groovy script


I'm using ScriptRunner to create a custom email based on a transition postfunction. 

In the email, I want to reference the component value(s) (component/s field) for a given issue. 

The following returns a null and not the value associated with the issue. 

Here's the line that's returning a null rather than the value:

<strong>Component:</strong> ${cfValues['Component\/s']}<br>

I'm assuming the either the issue is with the slash charachter or the value may not be retreivable via cfValues. 

Any help would be greatly appreciated.

1 answer

1 accepted

I created a custom label field called "Component/s" and set up a post-function that sends a custom email upon transitioning an issue from one status to the other. The code I used was a near direct copy and paste from what you've included above:

<strong>Component:</strong> ${cfValues['Component/s']}<br>

If the code you posted is directly from your JIRA instance, try removing the '\'  in "component\/s." If you don't have a Custom Field Value named "Component\/s," then you will get a NullPointerException as that field does not exist.

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Bridget Sauer
Published Thursday in Marketplace Apps

Calling all developers––You're invited to Atlas Camp 2018

 Atlas Camp   is our developer event which will take place in Barcelona, Spain  from the 6th -7th of   September . This is a great opportunity to meet other developers and get n...

327 views 0 6
Read article

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you