Accessing Forms & Elements without triggering events

Hi,
Nooby question here, I am trying to access all forms and all elements. However I seem to be triggering the onLoad event. Is there a way to avoid that?

TIA

The onload event is always triggered but never used when you don’t attach a method to it.

Is it really onload (which by the way is only available to a form) or is there something else going on?

Maybe onshow?

Its the onLoad. What I was trying to do was loop through all the forms & all the elements to capture the complete set of elements, I don’t want to load them, or show them, just referance them.

Hi,

tshepler:
Its the onLoad. What I was trying to do was loop through all the forms & all the elements to capture the complete set of elements, I don’t want to load them, or show them, just referance them.

When you reference them then Servoy needs to load them into memory and thus the unLoad event gets triggered.
I guess you can work around this by setting a global variable that these onLoad methods check like so:

if ( globals.bReferencingForms == true ) {
   return; // do nothing
}
// rest of your normal onLoad code

Hope this helps.

If you’re using 4.1.0? Why don’t use the solutionModel to get through all your forms and elements?
The solutionModel will not trigger any events, and even better: won’t consume all your memory with loading all your forms.

just start of with forms.allnames to get all formnames and then loop this array and use the solutionModel:

var $forms = forms.allnames
var $smForm;
var $smFields;

for(i = 0 ; i < $forms.length ; i++)
{
    $smForm = solutionModel.getForm($forms[i]);
    $smFields = $smForm.getFields;
}

This way you should separately do a ‘getButtons’, ‘getLabels’, etc. as the solutionModel is splitted by type, but it can be done…

Good luck!

Or use the allnames property on the forms object to get all formnames without them being loaded and then use the security.getElementUUIDs() function to get all names elements.

Question is why you want to loop through all forms and elements?

Paul

Thanks for the replies…

Why I started down this road was to try to get around the Servoy security. Since in 4.1 the groups security doesn’t work as advertised (multiple membership in groups defaults to the lowest access, not the highest access, fixed in 4.1.1) and while I was thinking about it, I might need to limit access at a more finite level than just group. So I was going to build a table of forms & elements & users & flags to set manually, then call at the Select Employer event to preset the visable elements. This method would only work if I could loop through all the forms quickly

The replies above have given me a few more tricks to try. Thanks again.