Business Rules Scripting beforePost event

from the documentation, beforePost event is fired on both the client and server.
I have tried this script and is not working:

function beforePost(row)
	if (isServer) {
		fail('beforePost event');

What am I missing?


What platform (.NET or Delphi) are you using?

Client - Delphi
Server - .NET
RO ver. on both platforms.
I have used DataAbstract .NET Core App template and changed .net version to 6.0.

Thank you,
I have done that, but then I have to do that in both places.
Can I write my own functions in javascript that are accessible globally?


You can create a new method and call it from both places. New method can be placed to Schema.Scripts section

Also you can call custom method that can be implement in .NET or Delphi code, like

  f: TDAEcmaFunction;
  f := func2;
function TServerDataModule.func2(args: array of variant): variant;

Logged as bugs://D19326.

I have tried that, but it didn’t work - getting the error:

Script runtime error in onNewRow: (5/0) 'newId' is undefined.

I have defined function newId() in global scripts:

And in table script event onNewRow:

My global function newId() has to work from the client and server side - is that possible?


open your .daSchema with text editor and find your beforePost method.

parent node should contain <RunOnClientAndServer>True</RunOnClientAndServer> child.
if it is <RunOnClientAndServer>False</RunOnClientAndServer> then change value to True.
it should be like

	<Script>// Called before a change to a record is accepted. Call the global fail() method from here to stop the change from occuring
function beforePost(row)
	if (isServer) {
		fail('beforePost event');

Can you retest original issue, pls? will this event be raised on server too?

Yes, it was set to False.
When I change it to True, the event is raised on the server also.
Is this a bug, do I need to change it to True on all tables?

And, can you look at my previous post - how to call global function?


yes, this is a bug.

Client-side has no access to Schema.Scripts by security reasons so it won’t work. Sorry.

OK, all clear now.

bugs://D19326 was closed as fixed.