Not able to Add Mfr Part Number via Java

Hi, i try to add a Mfr Part Number to an Item (even released and unreleased Item). I used the sample from Oracles SDK for Agile 9.3.2, but i get the following error (the error happens when the function “createRow” is called):

Cannot invoke method getCell() on null object org.codehaus.groovy.runtime.InvokerInvocationException: com.agile.agileDSL.ScriptObj.AgileDSLException: Cannot invoke method getCell() on null object at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:92) at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:230) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:912) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:756) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:672) at groovy.lang.GroovyObjectSupport.invokeMethod(GroovyObjectSupport.java:44) at groovy.lang.Script.invokeMethod(Script.java:78) at com.agile.agileDSL.ScriptMgr.ScriptMgr.executeMethod(ScriptMgr.java:127) at com.agile.agileDSL.ScriptMgr.ScriptMgr.execute(ScriptMgr.java:33) at com.agile.agileDSL.ScriptMgr.AgileDSLMgrSessionBean.invokeAction(AgileDSLMgrSessionBean.java:49) at com.agile.agileDSL.ScriptMgr.AgileDSLMgrSessionBean_3nrrgd_EOImpl.__WL_invoke(Unknown Source) at weblogic.ejb.container.internal.SessionRemoteMethodInvoker.invoke(SessionRemoteMethodInvoker.java:32) at com.agile.agileDSL.ScriptMgr.AgileDSLMgrSessionBean_3nrrgd_EOImpl.invokeAction(Unknown Source) at com.agile.soa.event.handler.ScriptInitiator.invoke(ScriptInitiator.java:92) at com.agile.soa.event.handler.ScriptInitiator.invoke(ScriptInitiator.java:60) at com.agile.soa.event.eventmgr.EventMgr.invokeEventHandlers(EventMgr.java:257) at com.agile.soa.event.eventmgr.EventMgrSessionBean.sendEvent(EventMgrSessionBean.java:119) at com.agile.soa.event.eventmgr.EventMgrSessionBean_naafhr_EOImpl.__WL_invoke(Unknown Source) at weblogic.ejb.container.internal.SessionRemoteMethodInvoker.invoke(SessionRemoteMethodInvoker.java:32) at com.agile.soa.event.eventmgr.EventMgrSessionBean_naafhr_EOImpl.sendEvent(Unknown Source) at com.agile.soa.event.eventmgr.EventUtil.sendEvent(EventUtil.java:73) at com.agile.soa.event.eventmgr.EventUtil.sendEvent(EventUtil.java:99) at com.agile.soa.event.eventmgr.EventUtil.sendUpdateTableEvent(EventUtil.java:499) at com.agile.soa.event.eventmgr.EventUtil.sendUpdateTableEvent(EventUtil.java:474) at com.agile.pc.cmserver.base.CMSessionBean.triggerUpdateTableEvent(CMSessionBean.java:9077) at com.agile.pc.cmserver.base.CMSessionBean.appendUpdateRow(CMSessionBean.java:2579) at com.agile.pc.cmserver.item.ItemSessionBean.appendUpdateRow(ItemSessionBean.java:2603) at com.agile.pc.cmserver.item.ItemSessionBean_v9sfth_EOImpl.__WL_invoke_1(Unknown Source) at com.agile.pc.cmserver.item.ItemSessionBean_v9sfth_EOImpl.__WL_invoke(Unknown Source) at weblogic.ejb.container.internal.SessionRemoteMethodInvoker.invoke(SessionRemoteMethodInvoker.java:32) at com.agile.pc.cmserver.item.ItemSessionBean_v9sfth_EOImpl.appendUpdateRow(Unknown Source) at com.agile.pc.cmserver.item.ItemSessionBean_v9sfth_EOImpl_WLSkel.invoke(Unknown Source) at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:695) at weblogic.rmi.cluster.ClusterableServerRef.invoke(ClusterableServerRef.java:230) at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:520) at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:363) at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:146) at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:516) at weblogic.rmi.internal.wls.WLSExecuteRequest.run(WLSExecuteRequest.java:118) at weblogic.work.ExecuteThread.execute(ExecuteThread.java:256) at weblogic.work.ExecuteThread.run(ExecuteThread.java:221) Caused by: com.agile.agileDSL.ScriptObj.AgileDSLException: Cannot invoke method getCell() on null object at sun.reflect.GeneratedConstructorAccessor272.newInstance(Unknown Source) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:526) at org.codehaus.groovy.runtime.MetaClassHelper.doConstructorInvoke(MetaClassHelper.java:535) at groovy.lang.MetaClassImpl.doConstr  

Here is my code:

import java.util. *; import com.agile.api.*; public class MCORedlineExample { public static final String USERNAME = "admin"; public static final String PASSWORD = "123"; public static final String URL = "http://plmtest:7001/Agile"; public static void main(String[] args) { try { IAgileSession myServer = connect(); String mytest = redlineAML(myServer); myServer.close(); } catch (APIException e) { System.out.println("APIException encountered!!!"); e.printStackTrace(); } catch (Exception e) { System.out.println("Exception encountered!!!"); e.printStackTrace(); } } /** * <p>Connect to Agile Server * </p> * * @return myServer An IAgileSession object * @throws APIException */ private static IAgileSession connect() throws APIException { IAgileSession myServer = null; AgileSessionFactory instance = AgileSessionFactory.getInstance(URL); HashMap params = new HashMap(); params.put(AgileSessionFactory.USERNAME, USERNAME); params.put(AgileSessionFactory.PASSWORD, PASSWORD); myServer = instance.createSession(params); return myServer; } private static String redlineAML(IAgileSession myServer) throws APIException { IAttribute attrPrefStat = null; IAgileList listvalues = null; Map params = new HashMap(); // Get a released item IItem item = (IItem)myServer.getObject("Part", "000000015"); // Get the Preferrred status value IAgileClass cls = item.getAgileClass(); attrPrefStat = cls.getAttribute(ItemConstants.ATT_MANUFACTURERS_PREFERRED_STATUS); listvalues = attrPrefStat.getAvailableValues(); listvalues.setSelection(new Object[] { "Preferred" }); // Create an MCO //IChange change = (IChange)myServer.createObject(ChangeConstants.CLASS_MCO, "MJ1"); IChange change = (IChange)myServer.getObject(ChangeConstants.CLASS_MCO, "M000024"); // Set the Workflow ID of the MCO change.setWorkflow(change.getWorkflows()[0]); // Get the Affected Items table ITable affectedItems = change.getTable(ChangeConstants.TABLE_AFFECTEDITEMS); // Add a new row to the Affected Items table IRow affectedItemRow = affectedItems.createRow(item); // Get the Redline Manufacturers table ITable redlineAML = item.getTable(ItemConstants.TABLE_REDLINEMANUFACTURERS); // Add a manufacturer part to the table params.put(ItemConstants.ATT_MANUFACTURERS_MFR_PART_NUMBER, "942339395101"); params.put(ItemConstants.ATT_MANUFACTURERS_MFR_NAME, "asd"); params.put(ItemConstants.ATT_MANUFACTURERS_PREFERRED_STATUS,listvalues); redlineAML.createRow(params); System.out.println("Done"); return "test"; } }

Agile User Asked on November 28, 2019 in Software Development Kit (API).
Add Comment
2 Answer(s)

Hi Gunni,

I think you need to change your params map to

params.put(ManufacturerPartConstants.ATT_GENERAL_INFO_MANUFACTURER_PART_NUMBER,
"942339395101"); params.put(ManufacturerPartConstants.ATT_GENERAL_INFO_MANUFACTURER_NAME,
"asd");

as the row needs to related to the MPN (ManufacturerPartConstants not ItemConstants)  Not sure if you can update the “Preferred Status” within the same params during the createRow, or if you have to update it after the row has been created.  Either way, the “Preferred Status” would remain an “ItemConstant” variable.

 

Agile Talent Answered on November 28, 2019.
Add Comment

Hi dmcdonald01,
when i try it like you think, i get the Error:

Error code :  60018
Error : message: Invalid parameter

Either with or without “Preferred Status”

Any idea?

Agile User Answered on November 29, 2019.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.