Error on groovy post function (Insight condition)

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

you can try 

import com.atlassian.jira.component.ComponentAccessor

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

regards

Thanos

Wow, thats just great ! Works perfectly.

Thanks a lot Thanos, you're awesome smile

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Bridget Sauer
Published Thursday in Marketplace Apps

Calling all developers––You're invited to Atlas Camp 2018

 Atlas Camp   is our developer event which will take place in Barcelona, Spain  from the 6th -7th of   September . This is a great opportunity to meet other developers and get n...

362 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