Skip to main content
10-Marble
October 1, 2018
Question

promoting a Object to Released state the previous released iteration is not autoset to Obsolete

  • October 1, 2018
  • 2 replies
  • 2009 views
Hi, I want to automatically set the previous "Released" document to "Obsolete" when a newer revision is promoted to "Released".  This is to avoid having older revisions still having their life cycle state remaining "Released".  I have this code from CS153831 which is just what I think will do the trick, but cannot correctly add it to the workflow.  I tried adding it to the approval transitions to no avail.
 
Thanks, Mark
 
 
wt.doc.WTDocument predecessor = (wt.doc.WTDocument) wt.vc.VersionControlHelper.service.predecessorOf((wt.doc.WTDocument) primaryBusinessObject);
if (predecessor != null)
predecessor=(wt.doc.WTDocument) wt.lifecycle.LifeCycleHelper.service.setLifeCycleState(predecessor, wt.lifecycle.State.toState("Obsolete") );

2 replies

22-Sapphire I
October 1, 2018

The PrimaryBusinessObject for this workflow is likely a Change Request, not a WTDocument, so the code does not act on the document.  

Need the code to "navigate" from the change object to the resulting data to the resulting data's predecessor (previous Revision's last Iteration), and then set the state of it.  Or, from change object to Affected data.

For understanding, might want to:

- create a workflow template with just this

- initiate the workflow via admin UI and tie to a WTDocument directly (one with a previous Rev)

4-Participant
January 23, 2020

Hi

Did you get this to work? I'm after the exact same function.

 

Thanks

 

Pär