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

Script Runner script context not working

I'm trying to use a custom field to validate a Workflow Post Function, but it's not working, does anyone know what I'm missing?

((Map) issue.fields.customfield_10084)?.value == 'Value'

 

1 answer

You can't reference the values of a custom field this way. Try this script:

import com.atlassian.jira.component.ComponentAccessor

def cf = ComponentAccessor.getCustomFieldManager().getCustomFieldObject(10084)
issue.getCustomFieldValue(cf) == 'Value'

My jira is the clound version, I believe that I can not import anything

Sorry - wasn't paying attention. I usually work in the Server version. Try this:

issue.fields[10084] == 'Value'

No success, follow the error:

 

[Static type checking] - Cannot find matching method sr.json.issue.fields#getAt(int). Please check if the declared type is right and if the method exists. @ line 1, column 1.

Static type checking errors are warning and do not necessarily mean that it won't run.

I don't use cloud so I can't comment if this will work or not, but you should give it a try,

One idea I'm getting from reading the documentation is to try

issue.fields[10084]?.value == 'Value'

Thanks for the support Peter, but it still did not work, the answer follows:

2019-04-23 17:35:41.732 INFO - Condition didn't eval to true, exiting

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Jira

Managing Incidents - The roof is on FIRE!

The roof is on FIRE… network outages, broken processes, upset clients and employees. Each day seemed to bring more and more issues. Incidents were communicated via email, messengers (skype or teams) ...

121 views 0 1
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