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

We are happy to announce the new Windchill Customization board! Learn more.

Unable to delete reference document using API

GiridharJorapur
3-Visitor

Unable to delete reference document using API

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.

1 ACCEPTED SOLUTION

Accepted Solutions

This is for deleting referenced part on a Document, but the procedure should be similar: https://support.ptc.com/appserver/cs/view/solution.jsp?n=CS197244

View solution in original post

2 REPLIES 2

This is for deleting referenced part on a Document, but the procedure should be similar: https://support.ptc.com/appserver/cs/view/solution.jsp?n=CS197244

Thanks for the response.

It is working as expected.

Top Tags