I am trying to prevent user from creating a new record.
Therefore I hook my event before GetNew event.
My event is executed but it doesn’t stoping Kinetic from creating new record.
Use a BPM, not the UI.
BPM was my second option. However I thought that I missed something and this can be done easily in app-studio and I am just blind/dumb/uneducated in app-studio.
Always consider the server when enforcing data rules. Preventing something in the UI can be defeated by calling REST for example.
What if you want to prevent action only for this specific form? Then doing this directly from UI seems to be more “natural”.
callContextClient.AssemblyName will show you what form it is from. Use a condition to check that.
Keep in mind, the more stuff you try and throw into the client, the slower it will become.
You typically want to save that stuff for the server to deal with and let the client be reserved for GUI changes.
To give you an example:
You can also do it by ProcessID if you want to restrict it to only one specific custom menu instead of the screen everywhere.
I would suggest it may be more “familiar” to how we’ve always done it, but you’ll find it will make your access strategy easier if it’s all in one place. Also, it upgrades with less effort.
@hmwillett @Mark_Wonsil
I used BPM as you suggested. However we still have 2 open questions:
- Why my Event did not throw an exception?
- How to throw an exception from UI (and stop an execution of standard method) - as there might be many others scenarios where this will be needed.
Is not meant to. “Return Error” tells the other events that that specific event failed. If you were to want a message box, you would need to put an “on failure” branch on whatever called that event. If nothing else called it, nothing would happen.
It’s very rare you’ll ever have a situation where you need to block an event in the UI. The actions you’re trying to stop a user from doing are the business objects which run server side which is where BPMs come in. Disabling a user from doing something in the UI is usually done via row rules and actually disabling or making the field read only to prevent action in the first place.
The only way I can think of to block an action from the UI is to do an event before whatever native event makes the REST call, run some logic, then possibly do event-cancel? Maybe? I’m not even entirely sure that will work, honestly.