Insight post function condition: How can I set only EMPTY custom fields from an attribute?


I am trying to set up a post function that sets a JIRA custom field with the attribute value from a selected object, but only if that custom field is already empty. If it it empty, the post function should be skipped. I currently have this entered in the Condition box:

import com.atlassian.jira.ComponentAccessor
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.fields.CustomField

def cf = ComponentAccessor.getCustomFieldManager().getCustomFieldObject("customfield_xxxxx")
issue.getCustomFieldValue(cf) = null

I have had some success with this condition in the past if I use "!= null" but can't ever get the condition to recognise an empty custom field or a specific value.

Does anyone know where I've gone wrong?

3 answers


The import statement is wrong with the ComponentAccessor. This is how it should look:

import com.atlassian.jira.issue.CustomFieldManager;
import com.atlassian.jira.issue.fields.CustomField;
import com.atlassian.jira.component.ComponentAccessor;

CustomField cf = ComponentAccessor.getCustomFieldManager().getCustomFieldObject("customfield_xxxx");
if (issue.getCustomFieldValue(cf) == null) {
    // Do something

Same answer as above...

Same answer as above...

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Mar 13, 2019 in Marketplace Apps

Marketplace Spotlight: Marketing apps for Confluence to keep your teams working on the same page


236 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