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

Community Tip - Need to share some code when posting a question or reply? Make sure to use the "Insert code sample" menu option. Learn more! X

Demotion on Promotion.

janderson
3-Visitor

Demotion on Promotion.

Hello all,

I am attempting to set up a promotion workflow, where after the state is set for the document in question, it takes all past released drawings and sets their state to "Obsolete". My knowledge of Java is minimal. My resident Java expert was "downsized" a few days ago and I'm a creek without a paddle on this little project. So any help would be greatly appreciated.

Attached is the workflow diagram where I have inserted the Change old Revision state. This is the script that is in that expression.

-------------------------------------------

if (primaryBusinessObject != null) {
try {
//First check if document has predecessors
if (wt.vc.VersionControlHelper.hasPredecessor((wt.epm.EPMDocument)primaryBusinessObject)) {
wt.fc.QueryResult qr = wt.vc.VersionControlHelper.service.allVersionsOf((wt.vc.Versioned)primaryBusinessObject);
java.util.Vector v = qr.getObjectVectorIfc().getVector();

// We basically get a Vector from the QueryResult, which is an Enumeration. Having a Vector makes it easy to
// to skip the first document in the list, which is the latest version and should not be changed.
// In the For-loop below, we are starting from Index 1 instead of 0 to skip the first Document.
for (int i=2; i< v.size(); i++) {
wt.epm.EPMDocument doc = (wt.epm.EPMDocument)v.elementAt(i);

// Finally, we check each of the predecessors and only reset State if State is RELEASED.
if (doc.getState().toString().equals("RELEASED")) {
System.out.println(" Workflow will reset LC State on Document " + doc.getNumber() + " " + doc.getIterationDisplayIdentifier());
wt.lifecycle.LifeCycleHelper.service.setLifeCycleState(doc, wt.lifecycle.State.toState("obsolete"));
}
}
}
else
//PBO has no predecessors. This is a new Object and do nothing
System.out.println(" ******* New obj");
}
catch (Exception e) {
}
}

----------------------------------------------------------------------------------------------------------------------------

I recieved this from PTC tech support who pretty much said here is starting point we can't help any farther.

and like I said, ANY help would be greatly appreciated.

1 REPLY 1

I received a few replies on this. Everyone said that it should work. However it is not. There are no errors anywhere in the log files to indicate that something is awry.

Does anyone have any suggestions?

Top Tags