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

Community Tip - New to the community? Learn how to post a question and get help from PTC and industry experts! X

How to check if a Document has any Document in its structure?

prathi
12-Amethyst

How to check if a Document has any Document in its structure?

I need to check if a given Document has any documents in its Structure. Depending on it I have to route Workflow.

ACCEPTED SOLUTION

Accepted Solutions

Hi Prasad,

You can use API to Navigates the WTDocumentUsageLink. It returns QueryResult of WTDocumentMaster.

QueryResult qr = WTDocumentHelper.service.getUsesWTDocumentMasters(doc);

Below is sample code snippet for your reference.

  ObjectIdentifier oid = ObjectIdentifier.newObjectIdentifier("wt.doc.WTDocument:314514");

  WTDocument doc = (WTDocument) PersistenceHelper.manager.refresh(oid);

  QueryResult qr = WTDocumentHelper.service.getUsesWTDocumentMasters(doc);

  while (qr.hasMoreElements()) {

         WTDocumentMaster master = (WTDocumentMaster)qr.nextElement();

         WTDocument latest = (WTDocument)wt.vc.VersionControlHelper.service.allVersionsOf(master).nextElement();

         System.out.println("Identity -> " + latest.getDisplayIdentifier().getLocalizedMessage(Locale.ENGLISH) + " & State -> " + latest.getState());

  }

I hope this helps you.

Regards,

Shirish

View solution in original post

1 REPLY 1

Hi Prasad,

You can use API to Navigates the WTDocumentUsageLink. It returns QueryResult of WTDocumentMaster.

QueryResult qr = WTDocumentHelper.service.getUsesWTDocumentMasters(doc);

Below is sample code snippet for your reference.

  ObjectIdentifier oid = ObjectIdentifier.newObjectIdentifier("wt.doc.WTDocument:314514");

  WTDocument doc = (WTDocument) PersistenceHelper.manager.refresh(oid);

  QueryResult qr = WTDocumentHelper.service.getUsesWTDocumentMasters(doc);

  while (qr.hasMoreElements()) {

         WTDocumentMaster master = (WTDocumentMaster)qr.nextElement();

         WTDocument latest = (WTDocument)wt.vc.VersionControlHelper.service.allVersionsOf(master).nextElement();

         System.out.println("Identity -> " + latest.getDisplayIdentifier().getLocalizedMessage(Locale.ENGLISH) + " & State -> " + latest.getState());

  }

I hope this helps you.

Regards,

Shirish

Announcements


Top Tags