I am using below code to delete a document reference from Part.
---
String strLinkId = new StringBuilder().append(WTIntrospector.getLinkInfo(WTPartReferenceLink.class).isRoleA("references") ? "roleAObjectRef" : "roleBObjectRef").append(".").append("key").toString();
QuerySpec queryLinkDetails = new QuerySpec(WTDocumentMaster.class, WTPartReferenceLink.class);
queryLinkDetails.appendWhere(new SearchCondition(WTPartReferenceLink.class, (String)strLinkId, "=", PersistenceHelper.getObjectIdentifier((Persistable)doc.getMaster())), 1, 1);
QueryResult queryLinkDetailsResult = PersistenceHelper.manager.navigate(part, "references", (QuerySpec)queryLinkDetails,false);
if (queryLinkDetailsResult.size() > 0){
while(queryLinkDetailsResult.hasMoreElements()){
WTPartReferenceLink wtpartlink = (WTPartReferenceLink)queryLinkDetailsResult.nextElement();
parVersion = part.getVersionIdentifier().getValue();
parIteration = part.getIterationIdentifier().getValue();
WTPart copart = (WTPart)com.ptc.windchill.enterprise.wip.WIPUtils.getCheckOutObject(part);
if (!WorkInProgressHelper.isWorkingCopy(copart)) {
copart = (WTPart)WorkInProgressHelper.service.workingCopyOf(copart);
Persistable localPersistable = PersistenceHelper.manager.delete(wtpartlink);
}
part = (WTPart)com.ptc.windchill.enterprise.wip.WIPUtils.getCheckInObject(copart,"Check In Comments");
parVersion = part.getVersionIdentifier().getValue();
parIteration = part.getIterationIdentifier().getValue();
}
}
-----
But some how it doesn't seem to work. But i see part is getting checked out and checked in.
Any help is greatly appreciated.