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

Hello,

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

This widget could not be displayed.

Hi,

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
}
This widget could not be displayed.

Same answer as above...

This widget could not be displayed.

Same answer as above...

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Aug 22, 2018 in Marketplace Apps

How a Marketplace app tech team is achieving gender diversity

Hello! My name is Genevieve Blanch, and I'm the Marketing Manager at RefinedWiki, creators of apps to give teams the tools to customize Atlassian platforms. Currently, 44% of the tech team at Re...

528 views 3 19
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