Hey Everyone,
So I have a button that when pressed it prefills a bunch of fields on the form. Instead of having to validate each individual field is there a way to validate that the button was pressed at least once before moving on?
The reason I don't want it to be on the individual fields because the button pulls the current information from the system and it adds human error to have them manually type it all correctly so instead they should click the button to prefill it.
I'm thinking perhaps create a variable and set it to false and if the variable is false then a message comes up saying they need to click the button if they try to leave the page, when you click the button it'll set the variable to true.
The problem is I'm not quite sure the syntax here and where to put the variable and syntax to check it upon page closing.
If there's a better way to do this let me know. Thank you!!!
If I understand your question - you want to make sure the button is pressed.
1) Have the button set a variable.
2) Then have page close logic to make sure the variable is set.
Yes, that's exactly what I'm trying to do. I'm looking for more specific help in syntax and how to set that up.
OK.
1) Inside the MEL for the button, I have it setting and OBS Code, although you might do the same with a document variable
2) Have another field (edit field) that displays/uses the OBS Code
2a) Advanced tab for that field, set Automated Page Close Handling to either Warning or Force
Note - there may need to be something else done here - all authorize and use page close handling. Goto Tools and Options, and near the bottom are settings for Page Close Handling. I think you need to 'check' the Include page close handlers option.
Just to elaborate on Joseph's response. Be aware that the state/value of a global variable will not persist if you put your form on hold. You are probably aware of that, but if the possibility exists that the user wants to put the document on hold without clicking the button and come back to it later, your form will not remember the previous state/value of a global variable. The best way to maintain the state of a variable after putting a form on hold is to create a visibility region somewhere on your form that is out of the way (perhaps at the very bottom of your form) and set the visibility expression to something that will always return a false value (i.e. since its only purpose is to monitor the state of a document variable).
Drop in an edit field control inside the visibility region you created and assign that edit field to a document variable (e.g. BUTTON_STATE).
Use a watcher expression to initially assign the value of the button state to "FALSE" when the user opens the form for the first time.
When the user clicks the button, include an expression in the function that is called to set the document variable (DOCUMENT.BUTTON_STATE) to "True".
You can then check the value of that variable when certain events occur to see if the user has clicked on the button (e.g. when user closes the form, when the user reopens the form, goes to another tab on the form, etc.)
I have included a screenshot of an example of this technique below along with the .DLG file. Feel free to import the clinical kit (it will deposit the form in Enterprise\Test) and give the form a test drive. You should be able to decipher the code in the DLG file pretty easily by referencing my comments in the code. I have included a page handler function to warn the user before they can sign or place the document on hold. The message will appear if the value of the BUTTON_STATE variable is "False", but it will still allow the user to close the form if they insist.
Here is the .dlg file if you would like to download: CheckButtonState
Happy coding,
Greg