Error on groovy post function (Insight condition)

Maxime Haddad
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!
September 13, 2016

Hey guys,

I created a post function from the add on Insight, in order to fill a custom field depending on condition.

My condition is pretty basic, I just want to verify is a field is null... if it isnt, fill a custom field.

Here is my groovy :

import com.atlassian.jira.ComponentManager;
import com.atlassian.jira.issue.IssueManager;
import com.atlassian.jira.issue.Issue;
import com.atlassian.jira.issue.CustomFieldManager;
import com.atlassian.jira.issue.fields.CustomField;
issue.getCustomFieldValue(11502)!=null

and the error:

jira.postfunction.InsightPostFunction] Error in groovy script:
groovy.lang.MissingMethodException: No signature of method: com.atlassian.jira.issue.IssueImpl.getCustomFieldValue() is applicablefor argument types: (java.lang.Integer) values: [11502]Possible solutions: getCustomFieldValue(com.atlassian.jira.issue.fields.CustomField), setCustomFieldValue(com.atlassian.jira.issue.fields.CustomField, java.lang.Object)

 

Do you have any hints for me?

 

Thanks

1 answer

1 accepted

2 votes
Answer accepted
Thanos Batagiannis [Adaptavist]
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 13, 2016

you can try 

import com.atlassian.jira.component.ComponentAccessor

def cf = ComponentAccessor.getCustomFieldManager().getCustomFieldObject(11502 as Long)
issue.getCustomFieldValue(cf) != null

regards

Thanos

Maxime Haddad
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!
September 13, 2016

Wow, thats just great ! Works perfectly.

Thanks a lot Thanos, you're awesome smile

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events