Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

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

Peter Evans
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
July 31, 2017

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

1 vote
Mathias Edblom
Contributor
August 16, 2017

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
}
0 votes
Mathias Edblom
Contributor
August 16, 2017

Same answer as above...

0 votes
Mathias Edblom
Contributor
August 16, 2017

Same answer as above...

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events