Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

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

Mouna Hammoudi
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 11, 2022

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

0 votes
Ram Kumar Aravindakshan _Adaptavist_
Community Champion
August 20, 2022

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

Mouna Hammoudi
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 18, 2023

Here is a screenshot of my configuration and I am using the even Issue Updated.Capture.PNG

Suggest an answer

Log in or Sign up to answer