Hello,
Greetings..
Currently i am in a project that deals with lifecycle state's. Though this project i had done long time ago, but now again redoing.
The problem is if user triggers the lifecycle state change, is there any way to halt the event triggered. Earlier i did project that happen to work when life cycle state is changed.
Now if user changes state from Work in Progress to Released, i dont want to go to released state and come back to Work in Progress, i am trying to fit a application between two states which allows to go to released state or bounce back to Work in Progress. Any inputs will be helpful.
Cheers,
Amit
Solved! Go to Solution.
Solved by orbjeff. Go to Solution.
Read Doug Redmond's blog called "Solving the The Four Eyes Problem". This should give you everything you need.
http://justonesandzeros.typepad.com/blog/2011/05/solving-the-four-eyes-problem.html
The quick answer is that you can add an event handler for the state transition:
DocumentServiceExtensions.UpdateFileLifecycleStateEvents.GetRestrictions += newEventHandler<UpdateFileLifeCycleStateCommandEventArgs>(UpdateFileLifecycleStateEvents_GetRestrictions);
Inside this method you can evaluate the "To" state and add a restriction if you don't want the state transition to proceed.
LfCycState toState = m_serviceManager.LifeCycleService.GetLifeCycleStatesByIds(new long[] { e.ToStateIds[i] }).First(); if (toState != null && toState.ReleasedState.Equals(true)) { e.AddRestriction(new ExtensionRestriction(maxFile.Name, " The transition has been blocked")); }
Your code will execute in the "UpdateFileLifecycleStateEvents_GetRestrictions" method before the transition occurs.
Hello Jeff Johnson,
Thanks for replying, the solution that you provided was indeed helpfull and it solved the problem. I was stuck in this for some time and it really helped.
Thanks again for providing a superb solution.
Cheers,
Amit