I have added a “sticky note” to my app. I also have a note field which is normally hidden except when a button is pushed to show it.
When the form is opened it hides the note if it is showing and sets the sticky note visible to whatever that patient’s account says - visible or invisible. The state is kept in a field/column ( I am a newbie, still unsure on nomenclature).
The code to toggle the sticky note is as follows
var currentstate=forms.patient_info_1.elements.sticky_note.visible
forms.patient_info_1.elements.sticky_note.visible=!currentstate
pat_sticky_note_visible = forms.patient_info_1.elements.sticky_note.visible
I then have a script that is activated when the form opens. It gives the error message
Cannot convert false to boolean
Here is the code used for that.```
forms.patient_info_1.elements.sticky_note.visible = forms.patient_info_1.pat_sticky_note_visible
What am I doing wrong <img src="{SMILIES_PATH}/icon_question.gif" alt=":?:" title="Question" />
Hi firestorm,
Maybe you defined pat_sticky_note_visible as a string field, so for using it as a boolen value you must compare it with == ‘true’ or ==‘false’. I would suggest that you can change it to an integer value and then use something like this for toggling the visibility:
forms.patient_info_1.elements.sticky_note.visible=!forms.patient_info_1.elements.sticky_note.visible;
pat_sticky_note_visible = forms.patient_info_1.elements.sticky_note.visible + 0;
where pat_sticky_note_visible is defined as integer, the + 0 is used to converts from boolean to integer, in javascript 0 is FALSE and 1 is TRUE
and in showing the form you can then use:
forms.patient_info_1.elements.sticky_note.visible = pat_sticky_note_visible;
hope it helps, ciao
Enrico,
That did it. Thanks a lot. Can you tell me where this is documented? I have looked but, could not find it.
Glad it worked,
The return type of .visible is boolean, and simply moving the sample in the method editor shows a good set-get visibility example.
I must admit that I have been programming since 1984 (yes I used punchcards) and using-LOVING Servoy since it’s beta version so I did not needed to search if boolean/string differences is documented… it surely is documented in Javascript manuals and most probably also somewhere in the Servoy documentation.