This may seem like an odd question, or maybe I’m missing an obvious answer. Forgive me as I’m just digging back into Servoy again after almost a year since my training.
I would like to have what is essentially an entire table/record treated as Global, or alternatively, I would like to define a set of Global fields that match a record/table structure, and have those Globals available throughout the application without having to define a relationship for all possible contexts.
If I understand correctly, it’s somewhat trivial to “copy” an entire record into a variable, but variables are not Globals and can not be put on a Form.
What I have is a set of “Project Defaults” that are setup as records in my DB. This table includes things like “User Field Names” and other data that is more or less “constant” for a given user/project. I want to load these into a Global area so I can reference them throughout the program, preferably without having to define each individual field name in the Globals/Variables section of the program.
An alternative would be just to have a table where you record those “configuration”, “session parameters” or whatever more-or-less persistant data.
Two interesting ways to get at that data from anywhere in a solution would be:
At start-up (or when that data becomes quite changeless), capture the foundset in a variable and start passing it around. This way it will always be accessible.
Have a relationship with a global field on the left side point to the desired foundset on that table. This way you have all the fields acessible solution wide.
mjekl:
An alternative would be just to have a table where you record those “configuration”, “session parameters” or whatever more-or-less persistant data.
Two interesting ways to get at that data from anywhere in a solution would be:
At start-up (or when that data becomes quite changeless), capture the foundset in a variable and start passing it around. This way it will always be accessible.
Have a relationship with a global field on the left side point to the desired foundset on that table. This way you have all the fields acessible solution wide.
HTH,
Miguel
Miguel:
Basically I’ve figured out solution 2, and this seems to work, though I’m not 100% I’ve implemented it correctly.
Number 1 sounds interesting, but how do you set up Global Variable that is a Record set? That does not seem to be one of the options for the Global Variable types. Could such a variable be used in a field on a form?
Basically I’ve figured out solution 2, and this seems to work, though I’m not 100% I’ve implemented it correctly.
What are you not sure about?
Lee said:
Number 1 sounds interesting, but how do you set up Global Variable that is a Record set? That does not seem to be one of the options for the Global Variable types. Could such a variable be used in a field on a form?
Ahh! If you declare a variable in a method without using the var keyword that variable is by default global and will outlive the method it was created in. Thus you can have one global variable defined in a start up script pointing at a foundset. That will always be available in your methods.
To use these values in forms labels can be used or “Virtual columns”. The condition is that these elements must have a name so that they can be programmatically accessed.
Frankly I rather use solution 1. It’s more flexible and allows for easier editing on screen!