Community
Vault Customization
Share your knowledge, ask questions, and explore popular Vault API, Data Standard, and VBA topics related to programming, creating add-ins, or working with the Vault API.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Prevent Event from triggering

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
amitnkukanur
385 Views, 2 Replies

Prevent Event from triggering

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

Senior Software Engineer
2 REPLIES 2
Message 2 of 3
orbjeff
in reply to: amitnkukanur

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.

Jeff Johnson
Technical Consultant
MasterGraphics Inc.
Message 3 of 3
amitnkukanur
in reply to: orbjeff

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

Senior Software Engineer

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report