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

Community Tip - You can subscribe to a forum, label or individual post and receive email notifications when someone posts a new topic or reply. Learn more! X

Linking Described-By Documents to a Part Instance Best Practices

csavela
1-Newbie

Linking Described-By Documents to a Part Instance Best Practices

The below method seems to be working great but I was curious, since it's not documented, if there's a better way to do link described-by documents to a WTProductInstance2.

WTProductInstance2 instance = WTPartHelper.service.littleCreateDocLinks(instance, collection, false);

If you are wondering where I found this, it's being used by PartManagementHelper in the createRelationship() method. This PartManagmentHelper is a class called by some form processors, one in particularly is for the wizard that adds described-by documents to a part instance from the UI. I could use the createRelationship() method, but it's making a couple checks I've already handled so I went straight for the gold.

Thanks,

Chris

Windchill 10.2 M020, CPS15

2 REPLIES 2
acoash1
5-Regular Member
(To:csavela)

This should get you there too:

wt.part.WTPartDescribeLink linkToCreate = wt.part.WTPartDescribeLink.newWTPartDescribeLink(part, doc);

  PersistenceHelper.manager.save(linkToCreate);

Thanks for the reply Aaron.

Yes what you suggest will link a WTPart but not a wt.part.WTProductInstance2. I previously attempted this same sort of maneuver as shown below.

WTProductInstanceDescribeLink link = WTProductInstanceDescribeLink.newWTProductInstanceDescribeLink(instance, doc);

persistable = PersistenceHelper.manager.save(link);

Doing this I get the WTException,"The object is not a session iteration. You can not modify it." I assume the error has something to do with attempting to modify without locking it and/or getting a workable version of it. The WTProductInstance2 object does not implement Workable so I do not know how to perform a type of "check-out."

Top Tags