How to cancel change state by Solidworks PDM API

I use preState event and poCmd.mbCancel flag, but this flag doesnt work ?

This is the line that I’m using in my code.

poCmd.mbCancel = Convert.ToInt16(true);

Since the expected value for mbCancel is a short, the value needs to be converted to Int16 to work properly. See here for a clarification

It’s not super clear in the API docs but you have to set the value to true to cancel or false to allow the action. False is the default. mbCancel Field - 2018 - SOLIDWORKS API Help