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

How to update EPMDocument name using LWCNormalizedObject

Newbie

How to update EPMDocument name using LWCNormalizedObject

Hello!

I'm trying to update name for EPMDocuments using the below code:

EPMDocumentMaster master = getMaster();

LWCNormalizedObject lwcObject = new LWCNormalizedObject(master,null,Locale.US,new UpdateOperationIdentifier());

lwcObject.load("name");

lwcObject.set("name", "newValue");

lwcObject.apply();

PersistenceHelper.manager.modify(master);

The above code fails with below exception:

com.ptc.core.meta.container.common.ConstraintException: The value for Name cannot be changed. Constraint Violation in isUpdateValid()

com.ptc.core.meta.container.common.impl.DefaultConstraintValidator.isUpdateValid(DefaultConstraintValidator.java:199)

com.ptc.core.meta.container.common.impl.BasicAttributeContainer._put(BasicAttributeContainer.java:2819)

com.ptc.core.meta.container.common.impl.BasicAttributeContainer._put(BasicAttributeContainer.java:2627)

com.ptc.core.meta.container.common.impl.BasicAttributeContainer.put(BasicAttributeContainer.java:947)

com.ptc.core.meta.type.common.impl.DefaultTypeInstance.put(DefaultTypeInstance.java:1023)

com.ptc.core.lwc.server.LWCNormalizedObject.set(LWCNormalizedObject.java:441)

The below code works but is hideously slow:

EPMDocumentMasterIdentity id = EPMDocumentMasterIdentity.newEPMDocumentMasterIdentity(master);

id.setName("newValue");

IdentityHelper.service.changeIdentity(master, id);

My question is if anyone knows how to change name for EPMDocumentMasters in a fast and efficient way?

Preferably I would like to use the first piece of code because that will allow for batch updates.

Maybe some kind of property needs to be set?

I would also like to update versioned attributes using first piece of code without iterating the object.

Does anyone know how to disable this check?

Cosistency with workspaces are not important i.e. the reason for this restriction I believe .

Thanks and best regards,

Peter

1 REPLY 1
Highlighted

Re: How to update EPMDocument name using LWCNormalizedObject

Hi Peter

LWCNormalizedObject is not for changing Name and Number

Try this code this will work



EPMDocumentMaster epmMaster=(EPMDocumentMaster) epmDoc.getMaster();


EPMDocumentMasterIdentity epmMasterId =(EPMDocumentMasterIdentity) epmMaster.getIdentificationObject();


epmMasterId.setName("01-2_CRANKSHAFT_MANI.ASM");


IdentityHelper.service.changeIdentity(epmMaster,epmMasterId);

Regards

Mani