Skip to main content

Hi,

I wrote this query with tsf_send_message

if @locatie_kraan_1 = 1 and @rij > 15
exec tsf_send_message 'ERROR_VERKEERDE_RIJNUMMER_1', null, 1


After i edit a row with @rij > 15 it shows the pop up message but it still proceeds to save it with the old value. How can i get it to cancel the save?

 

Hi, 

Did you write this query in the Default procedure or in the Trigger?


@Mark Jongeling 

I wrote it in the Default


When using @abort = 1 for the past parameter of tsf_send_message, the GUI will abort the operation last done and revert it to its original value; in your case the old value.

The GUI responds the following way:

Example

Code used:

if len(@residence) > 1
exec tsf_send_message 'no', null, 1;

What you can do about it depends on what you would like to happen. If you want to block the user from saving, that is possible by also making use of a layout with the same condition.

The default procedure should be changed to @abort = 0:

if @locatie_kraan_1 = 1 and @rij > 15
exec tsf_send_message 'ERROR_VERKEERDE_RIJNUMMER_1', null, 0

Then have a Layout procedure that disables the Save button:

if @locatie_kraan_1 = 1 and @rij > 15
select @confirm_button_type = 1

This way the user cannot save. Now @rij will stay at 50 even though it's incorrect but it does prevent the user from saving. 

Does this answer your question?:wink:


@Mark Jongeling 

When i edit it now and i change “Rij” from 14 to 20 and i press on ok in the pop up it saves it to 20 when i'm not allowing it to save it above 15 in the query. If you change the “Rij” value and from there directly press the save button you still can save it as 20


Demonstration

See the above GIF of how I created the example. The GUI should not allow saving when the confirm button is disabled. The layout procedure will be executed between changing the value and actually saving. 

Are you sure the Layout procedure is being used by the GUI? 

SF

 


@Mark Jongeling 

I've got it to work but now the question is when i change the number from 14 to 20 the button is disabled. If i put 14 back in i can't save until i press enter on my keyboard or press one of the other checkboxes. Is there another way without disabling the Save button? That just puts you back on the edit screen after pressing the save button? 


One way is having a Domain with a min. and max. value setting. The database will then create a Check constraint and therefore not allow the value to be higher than 15.

Limit → 0 to 15

 

Another is creating a Check constraint on the column like:

t1.col between 0 and 15
Check constraint

Both will create the same constraint, only the second one does is specifically for the given column whilst the first one does is for all columns with that Domain.

Hope this helps you out!


Reply