Skip to main content
10-Marble
May 10, 2023
Solved

Unable to create a new NmOid for new EPMDocument

  • May 10, 2023
  • 1 reply
  • 1226 views

I am using Windchill PDMLink Release 11.0 and Datecode with CPS F000

Creating a new NmOid for a new EPMDocument throws Exception: Cant' initialize an ObjectReference to Null.

Below is our code:
//Creating a new EPMDocument
EPMContextHelper.setApplication(EPMApplicationType.toEPMApplicationType("EPM"));
EPMAuthoringAppType at = EPMAuthoringAppType.toEPMAuthoringAppType("COCRDRAFT");
EPMDocumentType dt = EPMDocumentType.toEPMDocumentType("CADCOMPONENT");
EPMDocument cadDoc = EPMDocument.newEPMDocument("docnumber", "docName", at, dt, "CAD_DOC");
//Now create a new NmOid
NmOid cadNewNmOid = NmOid.newNmOid(cadDoc.getPersistInfo().getObjectIdentifier());

Could you let me know what is the problem here?


Here are the errors that I faced
wt.util.WTRuntimeException: ERROR: Can't initialize an ObjectReference to null

Best answer by MN_10661566

Yes. infact newNmOid needs String, and we changed to insert String instead of making EPMDocument persistent.

1 reply

HelesicPetr
22-Sapphire II
May 10, 2023

Hi @MN_10661566 

The trouble would be that new EPMDocument is not persisted and the ObjectIdentifier is null that moment?

I would check if getObjectIdentifier really returns somethnig.

 

I usually use oid to create NmOid object> NmOid.newNmOid("OR:wt.part.WTPart:00051210");

 

PetrH

MN_1066156610-MarbleAuthorAnswer
10-Marble
May 11, 2023

Yes. infact newNmOid needs String, and we changed to insert String instead of making EPMDocument persistent.