Three free tickets to Procurement & Supply Chain LIVE: Chicago. First come first served. Contact Dave Duncan at dduncan@ptc.com.
How to create WtPartUsageLink in windchill 11. 1 through API. I am looking for one Sample.
Solved! Go to Solution.
// work in process parent
// WorkInProgressHelper.service.checkout
WTPart parent;
WTPart component;
// create a Quantity
Quantity qty = new Quantity();
qty.setAmount(1);
qty.setUnit(QuantityUnit.EA);
// create the usagelink
WTPartUsageLink usageLink = WTPartUsageLink.newWTPartUsageLink(parent, component.getMaster());
// set the usagelink quantity
usageLink.setQuantity(qty);
// persist the usagelink
usageLink = (WTPartUsageLink) PersistenceHelper.manager.save(usageLink);
// work in process parent
// WorkInProgressHelper.service.checkout
WTPart parent;
WTPart component;
// create a Quantity
Quantity qty = new Quantity();
qty.setAmount(1);
qty.setUnit(QuantityUnit.EA);
// create the usagelink
WTPartUsageLink usageLink = WTPartUsageLink.newWTPartUsageLink(parent, component.getMaster());
// set the usagelink quantity
usageLink.setQuantity(qty);
// persist the usagelink
usageLink = (WTPartUsageLink) PersistenceHelper.manager.save(usageLink);
I'm having a problem with this. I am able to successfully add the child to the parent using this code, but later if I delete the parent and then try to checkout the child in the UI, it fails. I get a message saying the deleted parent is "deleted or inaccessible". The wtpartusagelink isn't cleaned up in the db when I delete the parent part. It still refers to the deleted part. Can you test this?
@dmcalister-2 wrote:
I'm having a problem with this. I am able to successfully add the child to the parent using this code, but later if I delete the parent and then try to checkout the child in the UI, it fails. I get a message saying the deleted parent is "deleted or inaccessible". The wtpartusagelink isn't cleaned up in the db when I delete the parent part. It still refers to the deleted part. Can you test this?
Works for me. You did not specify how you deleted the parent. I deleted the parent thru the UI.
Windchill 13.0.2.2
Deleted through the ui. It could be something else I'm doing in the code. Do you check the parent or child out/in? I'm not checking out the parent, but I do have to checkout the child to do some other things.
Windchill 12.1.2.9
Hi @KU_10670946
If the usage is not deleted, by system, you have to care about it.
That's all.
So if you delete the parent by code, you have to delete the all usage links
PetrH