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

Set Version of an EPMDocument (and WTPart)


Set Version of an EPMDocument (and WTPart)

Hi All,


I have written a checkin listener that should set a particular revision number (the iteration is not important) given a certain parameter passed by Creo (it is only done under special and particular circumstances). It only happens with parts and assemblies that are not already present in Windchill. This is the code I am using,


QueryResult qr = VersionControlHelper.service.allVersionsOf((Versioned) epmDocument);
long branchIdentifier = VersionControlHelper.getBranchIdentifier(epmDocument);
String revisionRetrieved = "D";

 while (qr.hasMoreElements()) {
                Iterated iterated = (Versioned) qr.nextElement();
                if (iterated.getBranchIdentifier() == branchIdentifier) {
                    MultilevelSeries mls = MultilevelSeries.newMultilevelSeries(epmDocumentMaster.getSeries());
                    VersionIdentifier vid = VersionIdentifier.newVersionIdentifier(mls);
                    //System.out.println("Inside vid: " + vid.getValue());
                    VersionControlHelper.setVersionIdentifier((Versioned) iterated, vid);
                } else {
                    System.out.println("iterated branch: " + iterated.getBranchIdentifier());
                    System.out.println("Base branch id: " + branchIdentifier);

Does anyone has any suggestion? Perhaps the checkin is the wrong event, and I should create a listener to a previous even (like upload)?


Thank you in advance!


After my testing below codes can change part version to B.1 , hope it can give you some ideas.

      String newVersion="B";
      MultilevelSeries mls = MultilevelSeries.newMultilevelSeries ("", newVersion);
      VersionIdentifier vid = VersionIdentifier.newVersionIdentifier(mls);
      IterationIdentifier iid = IterationIdentifier.newIterationIdentifier("1");
      WTPart new_Part = (WTPart) VersionControlHelper.service.newVersion(part,vid,iid);
      new_Part = (WTPart);

5-Regular Member

Did you ever get this working david? We're running into an issue with a similar scenario (matching revs) and right now we're looking at repeated revises to "catch up" (not ideal).


Can Creo utilize the OOTB Windchill property 'Initial Revision Parameter'?

Initial Revision Parameter.PNG


We are using it with SolidWorks to create new family member instances at the same revision as the generic file.


Kind regards,


So, you checkin a new number of an EPMDocument.

If the EPMDocument is a Creo Parametic Assembly or Part


the EPMDocument has a Windchill attribute with a value of whatever, set the revision to D (or whatever).


Which listener event are you keying off?


To test I wrote some code I'm running in a Windchill shell.

It's works.

Output is below:






5-Regular Member

We're using POST_MODIFY and checking if the EventTarget is A.1 then trying to set it's version to (in your example) D.


We're getting an error on save though: Object revision does not match branch revision

The problem is the object is already persisted to the dB.

So your code is a bit late to the party.

Remember you are triggered by POST_MODIFY so the object is already persisted, thus the error.


Also, I might add if you are keying of A.1 doesn't that not mean there is only one iteration of the master and therefore there's no need to use the query below as it would always return only one EPMDocument.  That being the EPMDocument you are passing to the allVersionOf() method

QueryResult qr = VersionControlHelper.service.allVersionsOf((Versioned) epmDocument);

You've got the EPMDocument so just cut to the chase and set it's revision.  No need for the loop.



5-Regular Member

Yes for sure, we're trying to do that but we get that error and were hoping your code would work but it looks like you're working with unpersisted Objects which of course wouldn't throw this error. 


We're just trying to make new CAD match the WTParts rev after an import but I can't find anything that works for it.  i've opened a ticket with customization team to see if they can assist me. 


Thanks for your responses, I understand I necro'd this post after a few years 😄

My test object IS persisted.  It's an old EMPDoc that I had in the dB.

So my approach would work for you.


If you need help send me a private message.



VersionControlHelper.service.changeRevision(part, "A", true); 

This is the payload load that we use.

I have this implemented and have had it working since 2004. Our business rule was that certain WTParts and EPMDocuments need to start at Version A not "-" (Dash) based on our Milspec version series. This essentially bumps them forward. Here is the main service but there are more classes as part of the Listener, using a POST_STORE Event.  I attached them as .txt files

I externalized some rules as a properties file:


# Properties for Goodrich Version Listener
# Goodrich Part Number Regular Expressions
#Letter followed by 2 digits, dash, 5 digits, dash, then 3 digits
#Letter followed by 2 digits, dash, then 5 digits
#Dash then 3 digits
#Rules for bumping initial version to A from dash "-"
#If version currently is at a dash
#and number matches the Goodrich Part Number format above
#and configuration portion at the end of the part number is greater than 1 but less than 100
#bump version to the next letter in the series which is A
#This applies to WTParts, EPMDocuments and WTDocuments in all contexts
#11-6-2019: New requirement is that config changes with -20X or -30X dash number also bump as well