Community Tip - Want the oppurtunity to discuss enhancements to PTC products? Join a working group! X
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!
...
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();
What determines the 'Master' relationship? Does that need to be declared at some point or is it implicitly done in Windchill by 'revisioning'?
Thanks!
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:
If you are wanting to learn more about this I would suggest taking a look at the training offered by felcosolutions.com:
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.
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);
}
Hi,
Below are the answers to your query:
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();