Hide the messagge "the data insert isn't in the value list"
I want hide the messagge in a field validated with a value list, I want prevent the user to select repair or leave the wrong value in the filed, how can I do that?
Which version of Filemaker are you using?
Assuming you are validating using is a member of value list, selecting do not allow user to overide, will prevent a value being submitted which is not a member of the value list in question.
I'm using fmp 11.
I want prevent the users to write in the listbox, they must only select a value
I have had this issue myself. It seems that FM allows data in the field to be overwritten. Even so, if that value is not a member of the list and you have validated it to be that way, an error should be dispalyed. If you dont allow overide that and do not allow data to be added to the list, this should be fine.
On thought though (I may implement this myself also), if you would like a user only to be able to select a value and not allow them to type a value, you could write a script that is triggered on key press for that field. If the key code is not that for tab, enter, return or up/down cursor keys, beep, and exit script with false as the parameter. This should beep when any but the aforementionrd keys have been pressed and prevent 'typing' the script will exit and the fale parameter will prevent the keypress from displaying.
how can I get the key code?
This should help for implementation: http://sixfriedrice.com/wp/script-triggers-using-the-keystroke-trigger/
Use decimal ascii character codes: http://www.asciitable.com/
As well as changing the validation, you could look at changing it to be a pop-up list (as opposed to a drop-down menu).
I am now thinking of implementing this myself.
The way I'm intending to do this is to allow auto-complete. Say, on key press in an empty field allow the key presses aforementioned, but also in the first instance of a key press, to allow a key through that equals the first letter of any value in the liist, then re-apply to the second, third and so on.
As well as changing the validation, you could look at changing it to be a pop-up list (as opposed to a drop-down menu)
Without testing right now, would changing to a pop-up allow full keyboard control on Mac and Windows using auto-compltete and no use of mouse?
"would changing to a pop-up allow full keyboard control" - Just tried it. Doesn't seem to on Windows XP.
I did this:
If the input value is on of five values, I launch the right script, if don't I launch an error script and nothing is done
One trick is to pass the current value of the field as a parameter to a script perfomed by the onObjectEnter script trigger that just saves that current value to a global variable such as $$PreviousValue. Then an OnObjectValidate trigger can be set to run your own validation script that checks the value entered against the list of values in the value list:
IsEmpty ( Filtervalues ( ValueListItems ; get ( FileName ) ; "ValueListNameInQuotes" ) ; Table::FieldBeingValidated ) )
If the field is not in the list, you can use the contents of $$PreviousValue to restore the original value. You can also use Show Custom Dialog to pop up your own validation message.
when I'm writing the script at "valueListItems" it gives me "table not found".
And where I must insert this code? in an if?
Yes this would be inside an if statement. I see I have a type in that example. See below for the correct syntax:
If [IsEmpty ( Filtervalues ( ValueListItems ( get ( FileName ) ; "ValueListNameInQuotes" ) ; Table::FieldBeingValidated ) ) ) ]
#data entered is not in value list
#data entered is in value list
now at the end of string it gives OPERATOR (e.g. "+";"-".....).
I typed the command:
IsEmpty ( Filtervalues ( ValueListItems ( get ( FileName ) ; "SIG" ) ; registro::sig ) ) )
Sigh. Sorry about that. Remove one ) from the end of the expression. Adding the extra ) was not needed.
IsEmpty ( Filtervalues ( ValueListItems ( get ( FileName ) ; "SIG" ) ; registro::sig ) )
no problem friend!! it works, now is there a way to return the focus on the validated field?
Exit Script [False]
Will keep the field from being exited by the user action that fired the trigger in the first place.
it don't works, the focus pass anyway to the next field
Can you post your script?
All three of these triggers:
OnObjectValidate, OnObjectSave, OnObjectExit
Execute before the user triggering event is processed. Thus Exit Script [False] will keep the cursor in the current field. I've used this method myself.
OnObject validate there isn't no script
if[registro::SIG="A" or registro::SIG="L" or ............. ]
set field [registro::DATA,get(datacorrente)]
set field [registro::ora,get(oracorrente)]
show custom dialog ("the insert value is not in the list")
set field [registro::DATA,""]
set field [registro::ora,""]
if[$$value <> registro::SIG and $$empty = 2] //$$value is the value of object on enter, $$empty is 1 if empy, 2 if filled
set field [registro::SIG;$$value)
At a quick glance you are not exiting the script with a false parameter - this is important.
As Phil says
When you tab/click/enter out of the field, the field is validated and then saved.
The tab/click/enter triggers the OnObjectValidate script. If you exit the the triggered script with the false parameter, the tab/enter/click (the action that triggered the script in the first place), will be cancelled as such.
Also I think you need move the Exit Script [FALSE] inside the the else part of the if statment otherwise it will always be executed.
Instead of using a Drop-down list use Pop-up menu.
Don't know what has happened to the formatting here, tried to edit?
If you are using Internet Explorer like I am right now, you'll find that editing text here is quite frustrating. The issues have been reported to Right Now and supposedly will be addressed with their next software update. In the meantime, you can apply formatting to a single word by putting it in its own paragraph, formatting it, and then deleting the extra returns to put it back in line with the rest of the sentence. A major inconvenience, but it does work.
Retrieving data ...