Call a button from a trigger
Is it possible to call a button from a table or field trigger. I have 2 applications for this.
1) I have a very long 'Trigger after update' on a table that was easer to work out as a series of buttons. I would like to just call those buttons instead of having to copy that code into the trigger and work out the issues that creates.
2) I have the same 'Trigger after update' several fields. It checks the important fields in the record for conflicts. Rather than having to insert (and later update) the code on each field I'd like to call it.
Being able to work out the code as a button has made testing of the code much easier.
14 replies
-
I like your use case... Lets state this a different way.... In NinoxDB.. Is there a way to create "global functions"?
Within a single formula .. I can create multiple functions like..
function F1() do .... end;
function F2() do ..... end;
F1();
F2();
So.. from within the trigger after update on a field.. I would like to call F1();
-
jim@jcschell.com ... Try this.. Create a field .. say "Validate Data Procedure". Move your button logic into 'Validate Data Procedure' trigger after update. Then... within other fileds trigger after update... Set the vlaue of this.'Validate Data Procedure' := now();
This effectively calls the Validate Data Procuedure "function". You can set 'Validate Data Procedure' display field only if to false.. so it does not appear on the data entry form. ;)
Have fun.
-
jim@jcschell.com ... Try this.. Create a field .. say "Validate Data Procedure". Move your button logic into 'Validate Data Procedure' trigger after update. Then... within other fileds trigger after update... Set the vlaue of this.'Validate Data Procedure' := now();
This effectively calls the Validate Data Procuedure "function". You can set 'Validate Data Procedure' display field only if to false.. so it does not appear on the data entry form. ;)
Have fun.
-
Oh, I realy liked where you were going with this.
I'm not getting it to work.
It seems that when a trigger updates the field "function" the 'trigger on update' for "function" does not run. it won't cascade triggers.
-
Yeah.. I just tried it myself.. It DOES work from the button.. but it does NOT work on other fields.. I put an example in the NX-Language-Tutorial.ninox sample database and sent it to support. I signed up for the Tuesday Webminar a few days ago.. I will ask them then.
-
Doing an RTFM (Read the fun manual) .. I see https://ninoxdb.de/en/manual/calculations/triggers which states "A trigger is an operation that is executed each time when the corresponding field is changed."
However.. it seems that the trigger is tied to a user interface action.. If change field value from a button call. it works.. or if I physically change the value .. it works.. but if I change the value as a result of a different field value.. it does not..
-
OK @jim.. Try this... MOVE each of your button forumulas to a table after update function. Create yes/no fields for each of your validation functions / buttons... These will be used to run just the functions that are set to true.. In the main ... evaluate the yes / no and run appropriate functions.. Effectively .. this allows you to test each validation function one at a time... When done testing.. you can set all the yes/nos to YES.. and the validations will fire whenever the record is updated..
Here is the table after update..
Here is the UI..
Here is the after update of the the field.. Only Run A .....
-
Here is the sample database... See 9. Working with Triggers..
http://mconneen.infointegrators.net/ninox/NX-Language-Tutorial.ninox
-
Mconneen - Great! Got it. That is a nice solution. A benefit of this is that combiations of function segments can be run together.
Thanks for your help. Jim
-
I recieved an email response from support ...
"This is intended behaviour. "onCreate" and "onChange" Trigger will not fire if they themselves triggered by a script. This is a safety feature." -
Which is a feature I exploit so tht I can force a field to become something that the user can not do them selves. that way I can make sure all the other things are already done.
-
I still want to call a button from a trigger, your solution notwithstanding.
-
I'm sad... I thought Ninox could a better low code solution, than the one we worked in numerous other projects before.
"This is intended behaviour. "onCreate" and "onChange" Trigger will not fire if they themselves triggered by a script. This is a safety feature."However, for logical operations, this is ery necessary in order not to multiplicate a lot of code with the potential associated inconsistencies and errors. At least ninox should have a switch that allows to fire a trigger by a change not caused by UI.
-
I'm sad... I thought Ninox could a better low code solution, than the one we worked in numerous other projects before.
"This is intended behaviour. "onCreate" and "onChange" Trigger will not fire if they themselves triggered by a script. This is a safety feature."However, for logical operations, this is very necessary in order not to multiplicate a lot of code with the potential associated inconsistencies and errors. At least ninox should have a switch that allows to fire a trigger by a change not caused by UI.
Content aside
- 2 yrs agoLast active
- 14Replies
- 6513Views