When i change a file's state from Work in Progress to Released, i automatically create Items and build an XML that will be used in my ERP system.
Now sometimes the file are missing certain properties which i need for my ERP so i want to cancel the state change.
When i change the state "DocumentServiceExtensions.UpdateFileLifecycleStateEvents.Pre" runs. I was thinking i can validate all properties here and if they are not correct i throw an exception to cancel the code. However even if i cancel the Pre event, the Post event will still run and the state will still be changed.
How can i cancel the UpdateLifeCycleStateEvent so that the files dont get their state changed or when the engineers press the change state button i can somehow intercept this button and run my own code before the button's event gets triggered.
Solved! Go to Solution.
When i change a file's state from Work in Progress to Released, i automatically create Items and build an XML that will be used in my ERP system.
Now sometimes the file are missing certain properties which i need for my ERP so i want to cancel the state change.
When i change the state "DocumentServiceExtensions.UpdateFileLifecycleStateEvents.Pre" runs. I was thinking i can validate all properties here and if they are not correct i throw an exception to cancel the code. However even if i cancel the Pre event, the Post event will still run and the state will still be changed.
How can i cancel the UpdateLifeCycleStateEvent so that the files dont get their state changed or when the engineers press the change state button i can somehow intercept this button and run my own code before the button's event gets triggered.
Solved! Go to Solution.
Solved by r.dejong92HFA. Go to Solution.
I wonder if you could use the lifecycle behavior configuration to restrict the transition if properties are not compliant. Could this be an option for avoiding custom programming?
I wonder if you could use the lifecycle behavior configuration to restrict the transition if properties are not compliant. Could this be an option for avoiding custom programming?
@Markus.Koechl Thanks for your reply.
Thats an option but I needed a bit more customization.
I ended up using "ItemService.UpdateItemLifecycleStateEvents.GetRestrictions += new EventHandler<UpdateItemLifeCycleStateCommandEventArgs>(UpdateItemLifecycleStateEvents_GetRestrictions);" to add restrictions and cancel the changing of the state this way.
@Markus.Koechl Thanks for your reply.
Thats an option but I needed a bit more customization.
I ended up using "ItemService.UpdateItemLifecycleStateEvents.GetRestrictions += new EventHandler<UpdateItemLifeCycleStateCommandEventArgs>(UpdateItemLifecycleStateEvents_GetRestrictions);" to add restrictions and cancel the changing of the state this way.
@r.dejong92HFA: sure - if you need extended rules, the customization leveraging the restriction is the path to go.
@r.dejong92HFA: sure - if you need extended rules, the customization leveraging the restriction is the path to go.
Can't find what you're looking for? Ask the community or share your knowledge.