AndyGB4
Posts: 122
|
Posted: 01/17/2013, 8:20 AM |
|
Hey everyone,
I have a record, that when someone inserts (or updates), it runs a certain function, and based the on the result returned, I would like to stop the form from submitting.
For example, if the value returned from the function is 0, then stop submitting the form.
Does anyone know a way to do this?
The function I wrote is being called in the BEFORE INSERT event, by the way.
|
|
|
Lucius
Posts: 220
|
Posted: 01/17/2013, 4:45 PM |
|
Hi,
Check those 2 topics in CCS help file:
-InsertAllowed Run-Time Property
-UpdateAllowed Run-Time Property
Not sure this is available in .NET though.
If not there is a very easy workaround.
In your Before Insert event change the Insert SQL to for example "Select 1;" if you wish to forbid the insert. This is described in help file under "Custom Insert Type Property" and "Custom Insert Property"
|
|
|
AndyGB4
Posts: 122
|
Posted: 01/18/2013, 8:01 AM |
|
Oh that's really clever! I'll give that a try.
Thanks!
|
|
|
AndyGB4
Posts: 122
|
Posted: 01/18/2013, 12:01 PM |
|
So I think the InsertAllowed Run-Time Property is only for PHP and a few other languages, but not C#..
And I tried this line of code in the BeforeInsert event:
((TableCommand)Select).SqlQuery = new StringBuilder("select 1;");
But the form was still inserted.
I'm pretty stumped on this one.
|
|
|
cvboucher
Posts: 191
|
Posted: 01/18/2013, 11:59 PM |
|
In the InMotion templates (which I know you aren't using but is what I know) there is an OnValidate for each field and for the form. Add one of the Validate actions to one of the OnValidate events. Then right click on the action and select Show Code to see how CodeCharge does validation. With this code you can also provide an error message to the end user.
HTH,
Craig
|
|
|
DataDoIT
|
Posted: 01/31/2013, 6:58 PM |
|
You'll want to use CmdExecution.
//Tasks_BeforeExecuteUpdate
if(DBUtility.UserId == item.user_id_assign_to.Value)
CmdExecution = false;
//Tasks_BeforeExecuteDelete
if(DBUtility.UserId == item.user_id_assign_to.Value)
CmdExecution = false;
//Tasks_BeforeExecuteInsert
if(DBUtility.UserId == item.user_id_assign_to.Value)
CmdExecution = false;
|
|
|