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

Community Tip - Want the oppurtunity to discuss enhancements to PTC products? Join a working group! X

How to update name using LWCNormalizedObject

PeterWigren
1-Newbie

How to update 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 EPMDocuments in a fast and efficient way?

Preferably I would like to use the first piece of code working.

Maybe some kind of property needs to be set?

Thanks and best regards,

Peter

2 REPLIES 2

Guess you have more luck if you post this question in the windchill section.

http://communities.ptc.com/community/windchill?view=discussions

Thanks!

I will try that!

/Peter

Top Tags