Skip to main content
12-Amethyst
April 7, 2025
Solved

replacing LWCNormalizedObject in code

  • April 7, 2025
  • 1 reply
  • 419 views

Good mornig,

I tried to use this code on WNC 12.1, replacing LWCNormalizedObject (deprecated) with PersistableAdapter:

 

private static void setIbaOnPartUsesOccurrence(PartUsesOccurrence puo, String ibaName, String ibaValue) throws WTException {
System.out.println("--------- Import.setIBAonPartUsesOccurrenc invoked on occurrence "+ puo.getName() +", with ibaName=" + ibaName + " and ibaValue=" + ibaValue);
wt.occurrence.UsesOccurrenceUserIBAs iba=wt.occurrence.UsesOccurrenceUserIBAs.newUsesOccurrenceUserIBAs(puo);
com.ptc.core.lwc.server.PersistableAdapter obj = new com.ptc.core.lwc.server.PersistableAdapter(iba,null,java.util.Locale.US,new com.ptc.core.meta.common.UpdateOperationIdentifier());

obj.load(ibaName);
obj.set(ibaName,ibaValue);
obj.apply();

wt.fc.collections.WTKeyedMap usesOccurrencesAndData = new wt.fc.collections.WTKeyedHashMap();
wt.fc.collections.WTCollection relatedUsesOccurrenceData = new wt.fc.collections.WTArrayList(); relatedUsesOccurrenceData.add(iba);
usesOccurrencesAndData.put(puo, relatedUsesOccurrenceData);
System.out.println("--------- Import.setIBAonPartUsesOccurrenc done");

wt.occurrence.OccurrenceHelper.service.saveUsesOccurrenceAndData(usesOccurrencesAndData);
}

 

No error found in MethodServer but no value set on the IBA. Parent part is checked-out.

Does anyone have any suggestion? tnx

Best answer by Emacp

I reply to my own post, clarifying that the code worked on the second attempt on another server. Evidently the IBA on my VM has some problem.

1 reply

Emacp12-AmethystAuthorAnswer
12-Amethyst
April 7, 2025

I reply to my own post, clarifying that the code worked on the second attempt on another server. Evidently the IBA on my VM has some problem.