Skip to main content
1-Visitor
August 1, 2014
Solved

How to delete the primarycontent of teh Document using api.

  • August 1, 2014
  • 1 reply
  • 1355 views

Hi friends,

How to delete the primarycontent of teh Document using api can you help me out.

Regards,

Sandeep

Best answer by ybagul

Following works with Windchill 10.2 M10

private boolean removePrimaryContent(final WTDocument wtDoc) {

boolean isSuccess = false;

ContentItem contentItem = null;

try {

contentItem = ContentHelper.service.getPrimary((FormatContentHolder)wtDoc);

if(contentItem != null){

System.out.println("deleting contentItem: " + contentItem.getDisplayIdentity());

PersistenceHelper.manager.delete(contentItem);

isSuccess = true;

}

} catch (WTException | PropertyVetoException e) {

isSuccess = false;

e.printStackTrace();

}

return isSuccess;

}

1 reply

ybagul1-VisitorAnswer
1-Visitor
August 1, 2014

Following works with Windchill 10.2 M10

private boolean removePrimaryContent(final WTDocument wtDoc) {

boolean isSuccess = false;

ContentItem contentItem = null;

try {

contentItem = ContentHelper.service.getPrimary((FormatContentHolder)wtDoc);

if(contentItem != null){

System.out.println("deleting contentItem: " + contentItem.getDisplayIdentity());

PersistenceHelper.manager.delete(contentItem);

isSuccess = true;

}

} catch (WTException | PropertyVetoException e) {

isSuccess = false;

e.printStackTrace();

}

return isSuccess;

}

saitha1-VisitorAuthor
1-Visitor
August 4, 2014

Hi yogesh,

Thank you,It is Working.

regards,

Sandeep