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

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

SOLVED
Newbie

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.

1 ACCEPTED SOLUTION

Accepted Solutions

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

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

1 REPLY 1

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

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