Combining a global variable boolean field with a trigger on table-level

I have a 

- boolean field called "Switch" that is a Global Variable in memory
- date field called "LastChange"
- a table with several fields of all types

Generally, any change on table level should trigger an update of LastChange

However, there are exceptions when for the sake of data consistency, changes need to be made without updating LastChange

In this case, Switch should be set to "false"

I've tried again and again with all different types of combinations but I simply can't get it to work, primarily because "in memory" variables are tricky if not buggy. 

The script on table level ("Trigger after update") should simply be

if Switch then
    LastChange := today()

But the "edit fields // trigger after update" script can't seem to properly communicate with the global variable "Switch"

I've also tried all sorts of methods and ended up with ridiculous complex scripts like

let x := LastChange;
let y:= today();
 if last((select DataBase).Switch) = true then
LastChange := x

Nothing seems to work, no matter what I try, either it always triggers the update or never triggers it.

4 replies

    • John_Halls
    • 2 mths ago
    • Reported - view

    Hi Ruben

    Your Global Field needs to be set at the start of your session, otherwise it will be blank. Either do this via a script or set the default value to Yes or No as required.

    Regards John

    • Ruben
    • 1 mth ago
    • Reported - view

    Thanks John,
    I am aware that Global Fields "default value" doesn't work and needs to be set via the entry script. 
    But this is different, there is a setting that I actively set back and forth. 
    The Global Field just doesn't work in the script, if it is "false", then the updating script should be skipped, but it only works if I use a button that is stored in the database (not cookie)

    However, I don't want one Boolean per database entry, I want a single Boolean on a Global Level 

    I hope the issue makes sense. 

    • John_Halls
    • 1 mth ago
    • Reported - view

    Hi Ruben

    I've been playing around with this and it looks like Global Fields work as expected in formula fields, and in Buttons, but not in Triggers, which seems like a bug to me. This might be worth reporting. I'd create a Globals table as a workaround for now.

    Regards John

    • Ruben
    • 1 mth ago
    • Reported - view

    Hi John, yes I also noted it works with scripts pertaining to buttons. 

    For now, I solved it as you said with an external and unlinked GeneralData table (with only one entry) with a normal variable Boolean called "Toggle" that I access from externally using record (GeneralData, 1).Toggle

    I still kept the Global Variable boolean which now change-triggers 
    let me := GlobalBoolean;
    record (GeneralData, 1).(Toggle := me)

    And the global change trigger now says
    if record (GeneralData, 1).Toggle then LastProcessed := today() end

    Only disadvantage is that the toggle switching now generates an unnecessary change log in GeneralData but at least it works as intended now.

Content aside

  • 1 mth agoLast active
  • 4Replies
  • 69Views
  • 2 Following