Skip to main content
15-Moonstone
March 14, 2018
Question

Deleting of all Windchill Documents using a custom utility

  • March 14, 2018
  • 1 reply
  • 1600 views

Hi,

 

Can someone please let me know how to delete the documents in a container using a custom utility. 

 

Which API has to be used accordingly. Can anyone share me the code snippet if possible.

 

Thanks and Regards,

Aditya

1 reply

aachanta15-MoonstoneAuthor
15-Moonstone
March 15, 2018

Hi All,

 

Kindly let me know if there are any inputs regarding the same.

 

Actually within a product if there are many documents resided in multiple folders. How to delete the documents from multiple folders and also outside the folder on one go.

 

Kindly let me know if there is concerned API regarding the same or if there is any utility for the same.

 

Thanks in advance.

 

Best Regards,

Aditya

16-Pearl
April 2, 2018

Hello @aachanta,

To search all WTDocument within context, you can try below snippet. I hope this helps you.

 

QuerySpec qs = new QuerySpec(WTDocument.class);
qs.appendSearchCondition(new SearchCondition(WTDocument.class,WTDocument.NAME,false));
qs.appendAnd();
qs.appendWhere(new SearchCondition(WTDocument.class,"containerReference.key.id", SearchCondition.EQUAL,lib.getPersistInfo().getObjectIdentifier().getId()), new int[]{0});
QueryResult qr = PersistenceHelper.manager.find((StatementSpec) qs);

Although I wrote it to fetch WTDocuments from Library, you can modify it to get WTDocuments from Product.

 

Once you have document you can then use below API to delete them:

 

PersistenceHelper.manager.delete(doc);

 

Thanks,

Shirish