How do I Automatically Assign Insight Object to Reporter (Jira User) on transition?

I'd like to automatically assign an Insight object (selected using an Insight single-select custom field) to a Jira user when a Jira Service Desk Issue type is closed, using the value in the 'Reporter' field.  I'm fairly new to Jira automation and Groovy scripting, but even so I can't seem to find any examples of doing this - seems to be the closest, but it apparently relies on custom fields (which 'Reporter' is not, I believe).  Perhaps there is a better process I could follow?  Any suggestions would be gratefully received, or even a basic guide to taking a non-custom value from a JSD issue and using it to assign an attribute to an Insight object would be very helpful if anyone can point me to one...



1 answer

1 accepted

Accepted Answer
1 vote

Hi Tom,

You would need to create a groovy script for this. You should be able to get the reporters username in your groovy using issue.getReporterUser().getUsername() 

Which give you access to the User according to documentation at

As you have access to the issue, you also have access to the following methods:

Using this, you should be able to assign the correct value in the mentioned groovy script. 

Best Regards

Hi Alexander,

Thanks so much for this info - it was exactly what I needed to assign the object to the reporter.  In case anyone else has this issue, all it took was a couple of simple modifications to the script at on lines 18 & 30:

 import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.issue.fields.CustomField;

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

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

/* Get the factory that creates Insight Attributes */
Class objectAttributeBeanFactoryClass = ComponentAccessor.getPluginAccessor().getClassLoader().findClass("");
def objectAttributeBeanFactory = ComponentAccessor.getOSGiComponentInstanceOfType(objectAttributeBeanFactoryClass);

/* Grabs the username of the Reporter */
def userNameAdd = issue.getReporterUser().getUsername();

/* This is the custom field where the object/s you want to set the value */
CustomField insightCustomField = ComponentAccessor.getCustomFieldManager().getCustomFieldObject(23456); // Change 23456 to the correct value
def insightObjects = issue.getCustomFieldValue(insightCustomField); // "issue" variable is always accessible in post function scripts.

/* This is the priority object type attribute and the one we want to modify */
def objectTypeAttributeBean = objectTypeAttributeFacade.loadObjectTypeAttributeBean(34567);

if (insightObjects != null) {
insightObjects.each{insightObject ->
/* Create the new attribute bean based on the value */
def newObjectAttributeBean = objectAttributeBeanFactory.createObjectAttributeBeanForObject(insightObject, objectTypeAttributeBean, userNameAdd);
/* Load the attribute bean */
def objectAttributeBean = objectFacade.loadObjectAttributeBean(insightObject.getId(), objectTypeAttributeBean.getId());
if (objectAttributeBean != null) {
/* If attribute exist reuse the old id for the new attribute */
/* Store the object attribute into Insight. */
try {
objectAttributeBean = objectFacade.storeObjectAttributeBean(newObjectAttributeBean);
} catch (Exception vie) {
log.warn("Could not update object attribute due to validation exception:" + vie.getMessage());

/* Done! :) */
return true;


Thanks again,



Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Oct 11, 2018 in Marketplace Apps

You + one app + a desert island...

Hi all! My name is Miles and I work on the Marketplace team. We’re looking for better ways to recommend and suggest apps that are truly crowd favorites, so of course we wanted to poll the Community. ...

3,664 views 6 6
Join discussion

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