Is there a way to update an existing document to have a newly created lifecycle?

We have a custom doctype that was using the Nuxeo “default” lifecycle. We found that we didn't like the states of “project,” “approved,” and “obsolete,” so we created a new custom lifecycle called “simple” with the states of “active” and “inactive.” After reading documentation, we find that only newly created documents will have the “simple” lifecycle, with existing documents retaining “default.”

How can we update all the existing documents that have the old lifecycle, to now use the new one? I've seen references to using “Document.FollowLifecycleTransition”, but that doesn't seem to work since it would still only follow the transitions of default. Ideally we would like to use an API call (bulk automation), but I have not yet found anything I could make work.

It seems like my only options are CoreSession.reinitLifeCycleState and Document.FollowLifecycleTransition, but I hope I'm just overlooking something. it would be nice if reinitLifeCycleState would reset the lifecycle to the new one, but I don't think that is how it works.

These are the related questions I've found, but none seem to be asking for the same thing as we need: https://answers.nuxeo.com/general/q/1c370e212dea46fba65903e63f237c16/CMIS-change-nuxeo-lifecycleState https://answers.nuxeo.com/general/q/36056e9d30ea481c9c154056627caa29/Can-i-change-Life-Cycle-State-through-REST-API https://answers.nuxeo.com/general/q/2cbffb4ccc9f4eb9810bd9f37cdd4682/Not-able-to-change-state-of-document-to-previous-state https://answers.nuxeo.com/general/q/86199415a6274b2b911a284c5fe44974/Can-I-set-the-Current-Life-Cycle-State-to-approved-using-studio

0 votes

1 answers

1130 views

ANSWER



Hello. I don't think this is something we support OOTB. The only possible think I guess is to use the same transition name.

0 votes



Yeah, there doesn't seem to be a way to do this OOTB. I haven't tried using a same transition name, since there would be a bit of work customizing the new lifecycle to have extra states/transitions to accommodate the attempt (and afterwards removing them). Support gave me some guidance on some possible Java contribution, but it seems the easiest is to just update the database values as needed. We are cloud so we don't have access to do that (although we could request for it to be done I suppose). Anyway, unless things change to add a feature OOTB, then it is best to plan lifecycles well when architecting the content model so that you don't have to change it later and run into these problems.
04/01/2021