starting a method on leave field

I have 2 global fields on a form.

globals.gebruikersnaam
globals.wachtwoord

and I’ve got the following method:

controller.find();
gebruikersnaam = globals.gebruikersnaam;
wachtwoord = globals.wachtwoord;
controller.search();
if(controller.getMaxRecordIndex()==0)
{
plugins.dialogs.showDialog(‘Waarschuwing’,‘Sorry, Geen geldige gebruikersnaam of wachtwoord!’,‘OK’)
controller.loadAllRecords()
controller.show()
}

On the field: global.wachtwoord I have set the property: OnLeave, to the method above. It won’t start when I am leaving the field.
What am I doing wrong?

This script performs a search on the table where the controller is build on.
Is this your intention? In other words , are the passwords stored in the same table as the controller is build on?

If not, you should build the same script on the form where the username and password are.

assuming:
scriptname is “checkPassword”
formName is “login”
formName is build on table users with fields “user” and “password”

..you could call this script via onLeave script attached to “globalField” on the controller like this:

onLeaveScript
forms.login.checkPassword();

PS: I assume you have a specific reason for handling passwords this way. (Servoy has a user/password check linked to security)

ah I found it. I must use: form.find()
I had copied the code from another script.

Strange thought, that the script works correctly when I attached it at a button!

I’m sorry, It did not work!
I’ve changed the code in this:

if(globals.gebruikersnaam == “”)
{
plugins.dialogs.showDialog(‘Waarschuwing’,‘U moet een geldige gebruikersnaam invullen!’,‘OK’)
return
}

form.find();
gebruikersnaam = globals.gebruikersnaam;
wachtwoord = globals.wachtwoord;
controller.search();
if(controller.getMaxRecordIndex()==0)
{
plugins.dialogs.showDialog(‘Waarschuwing’,‘Sorry, Geen geldige gebruikersnaam of wachtwoord!’,‘OK’)
form.loadAllRecords()
form.show()
}
else
{
plugins.dialogs.showDialog(‘Welkom’,'Welkom: ‘+voornaam+’ ‘+achternaam+’ ',‘OK’)
form.loadAllRecords()
form.show()
forms.relaties.controller.show()
}

But the script wonth start on leaving a global-field. If I change the global field to a normal field, than it starts. Is this a bug??

PS: I assume you have a specific reason for handling passwords this way. (Servoy has a user/password check linked to security)

Yes I know, but we always built ouer own acces to all ouer solutions. Why? :?: In practice, a lot of ouer users (customers) do not have the knowledge to administrate such a kind of login-structure. (some of them, can’t even read English!) So we build ouer own (simple) system, where a super-user can add another (new) user to the system and put this user in a categorie.
Categories are: Super-User, User (can’t delete records), Editer (can’t delete or create records, only edit) Guest (can only view data)
So the customer can simple administrate the solution.
My next question is: Can I automate the login (I mean the already built-in login) bij methods??
We do this in Filemaker, with a special plugin. DIALOGFM

HJK:
ah I found it. I must use: form.find()
I had copied the code from another script.

Strange thought, that the script works correctly when I attached it at a button!

This is an old syntax. (may still work, but is depricated)

I’m a little bit confused.
When do I use:

controller.find()

or

currentcontroller.find()

or assuming that de form is: actionDetails

forms.actionDetails.controller.find()

Can you explain the differences or when to use which one?
and can you explain why a script is not starting if it is set to leave on an global-field??

I’m sorry, It did not work!
I’ve changed the code in this:

Quote:
if(globals.gebruikersnaam == “”)
{
plugins.dialogs.showDialog(‘Waarschuwing’,‘U moet een geldige gebruikersnaam invullen!’,‘OK’)
return
}

form.find();
gebruikersnaam = globals.gebruikersnaam;
wachtwoord = globals.wachtwoord;
controller.search();
if(controller.getMaxRecordIndex()==0)
{
plugins.dialogs.showDialog(‘Waarschuwing’,‘Sorry, Geen geldige gebruikersnaam of wachtwoord!’,‘OK’)
form.loadAllRecords()
form.show()
}
else
{
plugins.dialogs.showDialog(‘Welkom’,'Welkom: ‘+voornaam+’ ‘+achternaam+’ ',‘OK’)
form.loadAllRecords()
form.show()
forms.relaties.controller.show()
}

But the script wonth start on leaving a global-field. If I change the global field to a normal field, than it starts. Is this a bug??

I’ve succesfully tested on the build that will be released soon.
You might check if this is a bug, by shortening the script to:

if(globals.gebruikersnaam == “”)
{
plugins.dialogs.showDialog(‘Waarschuwing’,‘U moet een geldige gebruikersnaam invullen!’,‘OK’)
return
}

This way you can at least check if the script is triggered with an onLeave Global.

Yes! this:

if(globals.gebruikersnaam == “”)
{
plugins.dialogs.showDialog(‘Waarschuwing’,‘U moet een geldige gebruikersnaam invullen!’,‘OK’)
return
}

is working!
Why is my script not triggered?

AH I FOUND THE BUG!
THe script is’nt triggering because I use globals.wachtwoord with displaytype: password. If I change it to TEXT_FIELD than the script is triggering!

The not triggering for password fields was a bug in servoy. Fixed in the next release.