Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Updating a custom field with an Insight Object attribute value during Issue Update event


Hello all,

I am trying to set a custom listener up that will take attribute values of an Insight Object and populate the custom fields when an issue is updated, just like the post function. I've found a few examples out there, but have basically drawn a blank here. 


I started with this script from Riada:

import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.issue.fields.CustomField;
import com.atlassian.jira.issue.Issue;
import com.atlassian.jira.issue.MutableIssue;
import com.atlassian.jira.event.type.EventDispatchOption;
import com.atlassian.jira.issue.context.IssueContextImpl;
import com.atlassian.jira.issue.fields.config.FieldConfig;  

/* Custom field for the organisation */
CustomField organisationCF = ComponentAccessor.getCustomFieldManager().getCustomFieldObject(10000);         
if (organisationCF == null || organisationCF.getValue(issue) == null) {    
return false;

/* Get Insight Object Facade from plugin accessor */
Class objectFacadeClass = ComponentAccessor.getPluginAccessor().getClassLoader().findClass("");  
def objectFacade = ComponentAccessor.getOSGiComponentInstanceOfType(objectFacadeClass);   

Class customFieldFacadeClass = ComponentAccessor.getPluginAccessor().getClassLoader().findClass("");  
def customFieldFacade = ComponentAccessor.getOSGiComponentInstanceOfType(customFieldFacadeClass); 

IssueContextImpl issueContext = new IssueContextImpl(issue.getProjectObject(), issue.getIssueType());
FieldConfig fieldConfig = organisationCF.getRelevantConfig(issueContext); 

def objectTypeAttributeName = null;
//objectTypeAttributeName = "JIRA User"  // Set an object type attribute name if you want to restrict the user fetch on just that type attribute. 

def objects = customFieldFacade.findUserObjectsByNormalCustomField(                                        
fieldConfig.getId(), currentUser,                                        

if (objects.isEmpty()) {    
return false;

def organisationTypeAttributeId = 123// The object type attribute id of the organisation attribute for the user object type.
def organisationObjectAttributeBean = objectFacade.loadObjectAttributeBean(objects[0].getId(), organisationTypeAttributeId);

if (organisationObjectAttributeBean == null) {    
return false;

MutableIssue mi = (MutableIssue) issue;
mi.setCustomFieldValue(organisationCF, [objectFacade.loadObjectBean(organisationObjectAttributeBean.getObjectAttributeValueBeans()[0].getReferencedObjectBeanId())]);
ComponentAccessor.getIssueManager().updateIssue(currentUser, mi, EventDispatchOption.DO_NOT_DISPATCH, false); 
/* We are done! */
return true;

All I want to do is take the attribute values and populate the custom fields. 


Any help is greatly appreciated. 

1 answer


Did you come right with this ?

I am trying to do something similar.

I have "reporter details" object in Insights. 

Attributes Department and Business Unit.


I want to update Jira custom fields "Business Unit" and "Department" on all tickets to the attributes above.

I would like this to do this with Automation, so that any changes are taken into account.

I can do it in the workflow on new issues, but need to update these fields for all pre-existing.

Help Please

Unfortunately, I have not been successful. I'm still working on it, but keep getting pulled away for other priorities. I have a scripting expert on my team now and hope that he may be able to work some magic. I'll keep you updated with our progress.

Like # people like this

Hallo Thomas,

any news?





Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Apps & Integrations

🍻🍂Apptoberfest Update: Upcoming Virtual Events 🎉

Hello Community! I hope you've been enjoying the 🍂Apptoberfestivities🍂 (I know I have!) The event is heating up next week with a series of virtual events that we're calling the 🍻🍂Partner App ...

462 views 5 18
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you