Skip to main content
4-Participant
June 6, 2018
Question

APIs to save UsesOccurrenceUserIBAs soft attribute values

  • June 6, 2018
  • 2 replies
  • 2347 views

I've found how to retrieve them (CS130100) but I cannot figure out how to save the soft attribute value on the Part Uses Occurrence.  Anyone have an example?

 

Thanks.

2 replies

bfobar4-ParticipantAuthor
4-Participant
June 6, 2018

TSE provided the solution, which I still could not find documentation for:

 

//orc is a PartUsesOccurrence object.
 
wt.occurrence.UsesOccurrenceUserIBAs iba=wt.occurrence.UsesOccurrenceUserIBAs.newUsesOccurrenceUserIBAs(orc);
 
com.ptc.core.lwc.server.LWCNormalizedObject obj = new com.ptc.core.lwc.server.LWCNormalizedObject(iba,null,java.util.Locale.US,new com.ptc.core.meta.common.UpdateOperationIdentifier());
 
//oiba01 is IBA name added into PartUsesOccurrence.
obj.load("oiba01");
obj.set("oiba01","setfromAPI");
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(orc, relatedUsesOccurrenceData);
 
wt.occurrence.OccurrenceHelper.service.saveUsesOccurrenceAndData(usesOccurrencesAndData);

 

Hope it helps someone else.

1-Visitor
January 8, 2024

it is works!!!! thank you

16-Pearl
June 7, 2018

Hi Ben,

Sorry to hear that you didn't exat documentation for this API. But I am also glad to hear that TS was able to get you some snippet here. 

I dig into this and found below knowledgebase articles around this (but not exactly the same). I hope this may help you somehow. 

https://support.ptc.com/appserver/cs/view/solution.jsp?n=116507

https://support.ptc.com/appserver/cs/view/solution.jsp?n=116504

https://www.ptc.com/en/support/article?n=CS162956

 

Regards,

Shirish