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

Community Tip - If community subscription notifications are filling up your inbox you can set up a daily digest and get all your notifications in a single email. X

Query for latest revision of WTDocument (current PrimaryBusinessObject)

kweiss
3-Newcomer

Query for latest revision of WTDocument (current PrimaryBusinessObject)

Hello,

I'm designing a workflow that will send out notifications at specific times post-due (i.e. 10 days late, 15 days late, etc.) and I'd like to end this workflow if the revision process for the specific WTDocument has started (i.e. AA.4 -> AB.1, so the AB revision exists in Windchill).  However, within a workflow for a specific revision of a WTDocument, I'm not sure how to query for the "latest revision" of the PrimaryBusinessObject since I believe this will only return the revision of the document that initiated the workflow.  Any thoughts?  Perhaps I've misunderstood something very simple.

Thanks!

7 REPLIES 7
RandyJones
19-Tanzanite
(To:kweiss)

...

However, within a workflow for a specific revision of a WTDocument, I'm not sure how to query for the "latest revision" of the PrimaryBusinessObject

Take a look at this post:

Re: Download Latest version/iteration of EPM document

Try something like this (not tested....):

WTDocument currentDoc = (WTDocument) PrimaryBusinessObject;

WTDocumentMaster docMaster = currentDoc.getMaster();

WTDocument latestDoc = (WTDocument)wt.vc.VersionControlHelper.service.allVersionsOf(docMaster).nextElement();

kweiss
3-Newcomer
(To:RandyJones)

What determines the 'Master' relationship?  Does that need to be declared at some point or is it implicitly done in Windchill by 'revisioning'? 


Thanks!

RandyJones
19-Tanzanite
(To:kweiss)

Kevin Weiss wrote:

What determines the 'Master' relationship?  Does that need to be declared at some point or is it implicitly done in Windchill by 'revisioning'? 


All iterated objects in Windchill have a master which is created the first time you create an object (wtdocument, epmdocument, wtpart, etc). There is one master in which "master" attributes such as number, name, fileName (if appropriate), and etc are defined. This is a core part of Windchill java objects and the underlying database tables. There is a database table for the master (wtdocumentmaster for documents) and a database table for the versions (wtdocument for documents). Some other database tables:

  • epmdocumentmaster
  • epmdocument
  • wtpartmaster
  • wtpart

If you are wanting to learn more about this I would suggest taking a look at the training offered by felcosolutions.com:

FELCO Solutions

I have taken both the "Windchill Automation" and the "Windchill Customization". Very good courses. The "Windchill Automation" extensively covers what you are attempting to do here.

sp-2
2-Explorer
(To:kweiss)

Hi,

You can use the following code to get the latest revision of PBO (WTDocument).

WTDocument latestDoc ;

String latestRev = "";

WTDocument currentDoc = (WTDocument) primaryBusinessObject;

QueryResult allDocVersions=VersionControlHelper.service.allVersionsOf((Versioned)primaryBusinessObject);

if(allDocVersions !=null && allDocVersions.size() > 0)

{

latestDoc=(WTDocument)allVersions.nextElement();

latestRev = latestDoc.getVersionIdentfier.getValue();

System.out.println("Latest Doc===="+latestDoc.getName()+"Latest Revision ===="+latestRev);

}



kweiss
3-Newcomer
(To:sp-2)

  1. Will I need to loop through AllDocVersions until I get to the latest version or will the QueryResult link the position of the PBO within it so that I only need to do nextElement() once?
  2. What is returned when I use .nextElement() and the PBO *is* the last element in the QueryResult?
sp-2
2-Explorer
(To:kweiss)

Hi,

Below are the answers to your query:

  1. Will I need to loop through AllDocVersions until I get to the latest version or will the QueryResult link the position of the PBO within it so that I only need to do nextElement() once? Yes
  2. What is returned when I use .nextElement() and the PBO *is* the last element in the QueryResult? Null
kweiss
3-Newcomer
(To:sp-2)

The following is what I came up with.  It seems precisely what I'm looking for.  Also, I appreciate the patience everyone has shown to a novice like me!

latestDoc = (wt.doc.WTDocument)allDocVersions.getObjectVectorIfc().lastElement();

Announcements

Top Tags