cancel
Showing results for 
Search instead for 
Did you mean: 

How to directly change lifecycle state

Lto_gripoche
Champ in-the-making
Champ in-the-making

Hello

Before our customers can work with Nuxeo DM we must import all the xml files and set them to a lifecycle state which is not the initial state. How can we do it ?

We tried setting the property ecm:currentLifeCycleState and using followTransition method but without any success (exceptions encountered).

Thanks

1 ACCEPTED ANSWER

Florent_Guillau
World-Class Innovator
World-Class Innovator

When creating a document through the CoreSession.createDocument(DocumentModel) method, you can set in the DocumentModel context data an indication of which initial lifecycle state it should be in instead of the default.

doc.putContextData(LifeCycleConstants.INITIAL_LIFECYCLE_STATE_OPTION_NAME, "yourInitialState")

BUT note that this is only possible for lifecycle states that have been marked as initial="true" in the lifecycle state definition.

View answer in original post

3 REPLIES 3

Benjamin_Jalon1
Elite Collaborator
Elite Collaborator

CoreSession expose the following method: reinitLifeCycleState that move the document to the initial state. Lifecycle is specifically design to manage it through available transitions.

But for mass import I suggest you to use our framework for import explain here. The github repository is here and you can look the project that is well explained.

You can create importer with the number of thread and the frequency for committing , etc...

Hope this will help.

Florent_Guillau
World-Class Innovator
World-Class Innovator

When creating a document through the CoreSession.createDocument(DocumentModel) method, you can set in the DocumentModel context data an indication of which initial lifecycle state it should be in instead of the default.

doc.putContextData(LifeCycleConstants.INITIAL_LIFECYCLE_STATE_OPTION_NAME, "yourInitialState")

BUT note that this is only possible for lifecycle states that have been marked as initial="true" in the lifecycle state definition.

Thanks a lot ! That's exactly what I was asking for.