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

Community Tip - Did you get called away in the middle of writing a post? Don't worry you can find your unfinished post later in the Drafts section of your profile page. X

Linking Described-By Documents to a Part Instance Best Practices

csavela
1-Visitor

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
10-Marble
(To:csavela)

This should get you there too:

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

  PersistenceHelper.manager.save(linkToCreate);

csavela
1-Visitor
(To:acoash1)

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."

Announcements

Top Tags