How can I select field config and check if Priority is listed there?

Hi,

I have a scripted field which checks history of the ticket and tells me if that ticket ever had a Critical set as a priority. This scripted field is set global to all the projects. Some of my projects does not use Priority field so, logs are telling me that scripted field fails because it could not find the Priority field for those projects. I would like to use fieldconfig scheme to check if the field is listed there or not and if not then exit out from script. Can you please tell me on how to use logic to check the field config scheme or any other options.

Error from log - 

2015-08-11 13:56:50,341 http-bio-8443-exec-780 ERROR rs044s 836x128500x1 1ctd4ni /secure/CommentAssignIssue.jspa [onresolve.scriptrunner.customfield.GroovyCustomField] Script field failed on issue: ABC-147, field: Scripted - Ever Critical 
java.lang.NullPointerException: Cannot get property 'name' on null object

Thank you so much,

Seema

2 answers

This widget could not be displayed.

could you post the code from the scripted field?

This widget could not be displayed.
Peter Bengov Community Champion Aug 11, 2015

As Alejo mentioned - an original script will help here.

My best guess is that you have an object you apply a '.name' command on, but you don't test before that if that object isn't null. This can be fixed by something like this, usually:

if (object != null)
   def variable = object.name;

Thanks for your reply Peter and Alejo. I have added if (issue.getPriority()!=null) condition and checking logs. I actually had done this to dev environment recently so thank you for guiding me to the right direction. Hopefully this will resolved my problem. Thank you again.

Suggest an answer

Log in or Sign up to answer
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted Wednesday in New to Jira

Are you planning to trial, or are currently trialling Jira Software? - We want to talk to you!

Hello! I'm Rayen, a product manager at Atlassian. My team and I are working hard to improve the trial experience for Jira Software Cloud. We are interested in   talking to 20 people planning t...

195 views 3 0
Join discussion

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