I am updating CMDB attribute from Jira custom filed value. My custom filed name is Status and CMDB object name is IT Asset and the attribute name is Status. I am updating the record based on the Attribute's name (IT Asset0 which is a custom column
I am getting the following error.
Script function failed on event: com.atlassian.jira.event.issue.IssueEvent, file: null groovy.lang.MissingMethodException: No signature of method:
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.issue.fields.CustomField;
import com.atlassian.jira.issue.Issue;
import com.atlassian.jira.issue.CustomFieldManager;
import com.atlassian.jira.user.util.UserManager;
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.event.type.EventDispatchOption;
import com.atlassian.jira.issue.context.IssueContextImpl;
import com.atlassian.jira.issue.fields.config.FieldConfig;
import com.atlassian.jira.bc.issue.IssueService
import com.atlassian.jira.issue.IssueInputParameters
import com.atlassian.jira.project.Project
import groovy.transform.Field
import com.atlassian.jira.issue.customfields.option.LazyLoadedOption
import com.atlassian.jira.config.SubTaskManager
import org.apache.log4j.Logger
import org.apache.log4j.Level
/* Globals */
def log = Logger.getLogger("com.glencore.SubtaskCreateUP")
log.setLevel(Level.DEBUG)
def issue = event.issue as Issue
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
/* Get Insight Object Facade from plugin accessor */
Class objectFacadeClass = ComponentAccessor.getPluginAccessor().getClassLoader().findClass("com.riadalabs.jira.plugins.insight.channel.external.api.facade.ObjectFacade");
def objectFacade = ComponentAccessor.getOSGiComponentInstanceOfType(objectFacadeClass);
/* Get Insight Object Attribute Facade from plugin accessor */
Class objectTypeAttributeFacadeClass = ComponentAccessor.getPluginAccessor().getClassLoader().findClass("com.riadalabs.jira.plugins.insight.channel.external.api.facade.ObjectTypeAttributeFacade");
def objectTypeAttributeFacade = ComponentAccessor.getOSGiComponentInstanceOfType(objectTypeAttributeFacadeClass);
/* Get the factory that creates Insight Attributes */
Class objectAttributeBeanFactoryClass = ComponentAccessor.getPluginAccessor().getClassLoader().findClass("com.riadalabs.jira.plugins.insight.services.model.factory.ObjectAttributeBeanFactory");
def objectAttributeBeanFactory = ComponentAccessor.getOSGiComponentInstanceOfType(objectAttributeBeanFactoryClass);
log.debug("Step 1")
/* This is the custom field with the value you want to add to an object attribute */
CustomField jiraCustomField = ComponentAccessor.getCustomFieldManager().getCustomFieldObject(111201); // Status Custom Filed
/* This is the custom field where the object/s you want to set the value */
CustomField insightCustomField = ComponentAccessor.getCustomFieldManager().getCustomFieldObject(107101); // IT Asset Custom filed
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(19166); // Status Attribute
log.debug("Step 2")
log.debug(jiraCustomField)
log.debug(insightObjects)
log.debug(objectTypeAttributeBean)
if (insightObjects != null) {
insightObjects.each{insightObject ->
/* Create the new attribute bean based on the value */
def newValue = issue.getCustomFieldValue(jiraCustomField);
log.debug("Step 3")
log.debug(newValue)
def newObjectAttributeBean = objectAttributeBeanFactory.createObjectAttributeBeanForObject(insightObject, objectTypeAttributeBean, newValue[0].getName());
//log.debug(newObjectAttributeBean)
log.debug("Step 4")
/* Load the attribute bean */
def objectAttributeBean = objectFacade.loadObjectAttributeBean(insightObject.getId(), objectTypeAttributeBean.getId());
log.debug("Step 5")
if (objectAttributeBean != null) {
/* If attribute exist reuse the old id for the new attribute */
log.debug("Step 6")
newObjectAttributeBean.setId(objectAttributeBean.getId());
}
log.debug(newObjectAttributeBean)
/* Store the object attribute into Insight. */
try {
objectAttributeBean = objectFacade.storeObjectAttributeBean(newObjectAttributeBean);
log.debug("Step 7")
} catch (Exception vie) {
log.warn("Could not update object attribute due to validation exception:" + vie.getMessage());
}
}
}
groovy.lang.MissingMethodException: No signature of method:
What method? It should say what method. Typically then you will find you are calling a non-existing method from the code, e.g. passing different amount of arguments, typo, something like that.
Thanks for your reply Radek!.
It is failing in the following line.
def newObjectAttributeBean = objectAttributeBeanFactory.createObjectAttributeBeanForObject(insightObject, objectTypeAttributeBean, newValue[0].getName());
I'm getting the following error.
Script function failed on event: com.atlassian.jira.event.issue.IssueEvent, file: null groovy.lang.MissingMethodException: No signature of method: com.atlassian.jira.issue.customfields.option.LazyLoadedOption.getAt() is applicable for argument types: (Integer) values: [0] Possible solutions: getAt(java.lang.String), putAt(java.lang.String, java.lang.Object), wait(), grep(), tap(groovy.lang.Closure), getClass() at Script1156$_run_closure1.doCall(Script1156.groovy:63) at Script1156.run(Script1156.groovy:59)
Regards
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.