Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,367,583
Community Members
 
Community Events
168
Community Groups

changeLog.internalDelegator [GenericEntity.get] "internalDelegator" is not a field of ChangeGroup

I am writing some scriptrunner listener code to be triggered when an issue of type impediment is updated and here is my code: 

import com.atlassian.event.Event
import java.util.HashMap;
import java.util.List;

import org.apache.log4j.Logger;
import org.ofbiz.core.entity.GenericValue;
import org.ofbiz.core.entity.GenericEntity;

import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.event.issue.AbstractIssueEventListener;
import com.atlassian.jira.event.issue.IssueEvent;
import com.atlassian.jira.issue.ModifiedValue;
import com.atlassian.jira.issue.MutableIssue;
import com.atlassian.jira.issue.fields.CustomField;
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder;
import com.atlassian.jira.issue.util.IssueChangeHolder;
import org.apache.log4j.Logger
import com.atlassian.jira.issue.Issue;
import com.atlassian.jira.component.ComponentAccessor
import java.util.HashMap;
import java.util.List;
import org.apache.log4j.Logger;
import org.ofbiz.core.entity.GenericValue;

def log = Logger.getLogger("atlassian-jira.log")
log.warn("Start Auto Defaults Listener");
log.warn("IssueMounaEvent = " + event);
Issue issue = event.getIssue();
log.warn("IssueMouna = " + issue);

if (issue.getIssueType().getName().equalsIgnoreCase("Impediment"))
{
log.warn("Analyzing IMPEDIMENT changelog Mouna ...");
event2= (IssueEvent) event;
def warning = analyzeImpedimentChangeLog(event2);

}




def analyzeImpedimentChangeLog(IssueEvent event) {
def warning = "";
log.warn("IMPEDIMENT STATUS ")
List<GenericValue> changeItems = null;
def impedimentStatus = event.getIssue().getStatus().getName();
log.warn("IMPEDIMENT STATUS "+impedimentStatus)
if (!"New".equalsIgnoreCase(impedimentStatus) && !"Inspecting".equalsIgnoreCase(impedimentStatus)) {

GenericValue changeLog = event.getChangeLog();
log.warn("HERE 1")

HashMap<String, Object> fields = new HashMap<String,Object>();
log.warn("HERE 2")

fields.put("group", changeLog.get("id"));
log.warn("HERE 3")

String author = changeLog.getString("author");
log.warn("HERE 4")
try{

log.warn("CHANGE LOG: "+changeLog.internalDelegator)

changeItems = changeLog.internalDelegator.findByAnd("ChangeItem", fields);
log.warn("HERE 5")
}catch(Exception e){
log.warn("EXCEPTIONMOUNA "+e)
}

}

return warning;
}
  

I receive the following error, which is kind of weird because this was previously implemented in Java and it worked fine: 

2022-08-11 EXCEPTIONMOUNA java.lang.IllegalArgumentException: [GenericEntity.get] "internalDelegator" is not a field of ChangeGroup

I would like to execute the following line of code:

changeItems = changeLog.internalDelegator.findByAnd("ChangeItem", fields); 

 and I receive the exception above when writing the following line of code into the log: 

log.warn("CHANGE LOG: "+changeLog.internalDelegator)

 This code was previously implemented as a Java plugin and it worked fine in this way. What needs to be done in this case in order to adapt this statement to groovy in ScriptRunner?

1 answer

Hi @Mouna Hammoudi

Could you please share a screenshot of your Listener configuration and please specify what type of event you are using for your listener?

Thank you and Kind regards,

Ram

Suggest an answer

Log in or Sign up to answer
TAGS

Atlassian Community Events