Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
badges earned

Your Points Tracker
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

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

ScriptRunner custom event listener Edited

Hi, this might be a bit techical.

The task is;

When one of two specific issue fields is changed:

  1. Update 2 other custom fields 
  2. Execute a HTTP request


The problem seems to be that originalissue global variable is unaccesible in the Listener. Is there a way to create a field changed listener instead of issue updated lisntener

The second thing is, some imports also do not seem accesible, though same code works perfectly in workflow post function set field value with Groovy.

Here's my code (please don't mind the issue global variable, I know that for Listeners it is event.getissue)

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 java.util.ArrayList;

public Object GetInsightObject(int key){
Class objectFacadeClass = ComponentAccessor.getPluginAccessor().getClassLoader().
def objectFacade = ComponentAccessor.getOSGiComponentInstanceOfType(objectFacadeClass);
return objectFacade.loadObjectBean(key);

public Object GetInsightObject(String key) {
Class objectFacadeClass = ComponentAccessor.getPluginAccessor().getClassLoader().
def objectFacade = ComponentAccessor.getOSGiComponentInstanceOfType(objectFacadeClass);
return objectFacade.loadObjectBean(key);

def GetInsightValue (int InsightObjectId, int InsightAttributeId) {
def insightObjectAttributeValueBeans = GetInsightObject(InsightObjectId, InsightAttributeId);
if (insightObjectAttributeValueBeans == null){
return null;
def insightValues = insightObjectAttributeValueBeans[0];
if (insightValues == null){
else {
def insightValue = insightValues.getValue();
return insightValue;

def GetInsightObject (int InsightObjectId, int InsightAttributeId){
Class objectFacadeClass = ComponentAccessor.getPluginAccessor().getClassLoader().findClass("");
def objectFacade = ComponentAccessor.getOSGiComponentInstanceOfType(objectFacadeClass);
Class objectTypeFacadeClass = ComponentAccessor.getPluginAccessor().getClassLoader().findClass("");
def objectTypeFacade = ComponentAccessor.getOSGiComponentInstanceOfType(objectTypeFacadeClass);
Class objectTypeAttributeFacadeClass = ComponentAccessor.getPluginAccessor().getClassLoader().findClass("");
def objectTypeAttributeFacade = ComponentAccessor.getOSGiComponentInstanceOfType(objectTypeAttributeFacadeClass);

def obj = objectFacade.loadObjectBean(InsightObjectId);
if (obj == null){
return false;
attribType = objectTypeAttributeFacade.loadObjectTypeAttributeBean(InsightAttributeId);
if (attribType == null){
return false;
def attrib = objectFacade.loadObjectAttributeBean(InsightObjectId, InsightAttributeId);
if (attrib == null){
return false;
def attribValues = attrib.getObjectAttributeValueBeans();
if (attribValues == null){
return null;
else {
return attribValues;

if( (issue.get("customfield_10226") != originalIssue.get("customfield_10226")) || (issue.get("priority") != originalIssue.get("priority"))){ //service or priority field updated
Class objectFacadeClass = ComponentAccessor.getPluginAccessor().getClassLoader().findClass("");

/* The reference to the object facade which you can use in your code */
def objectFacade = ComponentAccessor.getOSGiComponentInstanceOfType(objectFacadeClass);
def InsightObjectKey = issue.get("customfield_10226")
InsightObjectKey = InsightObjectKey[0].toString()
def tempkey = (InsightObjectKey=~/\(TSS-.*\)/)[0]
tempkey = tempkey.drop(1) // get object id
tempkey = tempkey[0..-2]
def objectID = objectFacade.loadObjectBean(tempkey).getId()

def react = 191
def react_critical = 193
def resolution = 192
def resolution_critical = 194
def priorityValue = issue.getPriorityObject.getName() //check priority value
if(priorityValue == 'P1' || priorityValue == 'P2'){ //
issue.setFieldValue("customfield_11200", GetInsightValue(objectID,react_critical)) //set new crit react time
issue.setFieldValue("customfield_11201", GetInsightValue(objectID,resolution_critical)) //set new crit resolution time
else if(priorityValue == 'P3' || priorityValue == 'P4'){ // check priority value
issue.setFieldValue("customfield_11200", GetInsightValue(objectID,react)) //set new react time
issue.setFieldValue("customfield_11201", GetInsightValue(objectID,resolution)) //set new resolution time

def SLA_id = issue.get("customfield_11100")[0].toString()[0]
//TODO http request here

0 answers

Suggest an answer

Log in or Sign up to answer
Community showcase

The benefits of using Jira in different departments

Jira is a great tool to use across different departments. Forget that paperwork – switch to Jira and get that tasks done smoothly. Marketing Jira allows for a complete digital transformation of you...

94 views 0 5
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