I have been updating a couple of forms and having trouble making some fields required. Two fields that are radio buttons (Yes or No) I have the advanced tab set to "Force" and "Change Appearance" but when form is imported the form just closes and popup message to complete form doesn't come up.
I also have page handlers for the form. Coding is below:
{IF OBSNOW("SURGLOCATION")="GH" OR OBSNOW("SURGLOCATION")="SJ" OR OBSNOW("SURGLOCATION")="WPH" OR OBSNOW("SURGLOCATION")="210 OR" OR OBSNOW("SURGLOCATION")="ASC" OR OBSNOW("SURGLOCATION")="SW Office" AND DOCUMENT.ASCEXCLUSIONS=="") THEN userok("Please enter Exclusions to ASC.") return closepage("TRUE") ELSE "" ENDIF}
{IF DOCUMENT.ULTRASOUND_G=="" OR DOCUMENT.IS_PATIENT_D=="" THEN userok("Please complete the required fields.") return closepage("TRUE") ELSE "" ENDIF}
The top half works but bottom doesn't. The bottom is what I need to make those fields required to fill out.
For some reason none of this seems to work in this form. The force and change appearance are working for me but not here.
If someone could let me out that would be great.
Thanks,
Mike
One place to check...
Inside VFE, click the Tools choice across the top row (File Edit ...)
Choose Options
Select the Build tab
Near the bottom you will see a section "Automatic Page Close Handler Options"
Is there a check-mark in front of "Include page close handlers"?
Sorry forgot to mention that. I have those settings checked off but still doesn't work with this particular form
OK, since that is ruled out...
In your first equation, I would surround all those OR statements by a set of parenthesis. Mixing AND with OR and not using parenthesis encourages weird results.
{(IF OBSNOW(“SURGLOCATION”)=”GH” OR
OBSNOW(“SURGLOCATION”)=”SJ” OR
OBSNOW(“SURGLOCATION”)=”WPH” OR
OBSNOW(“SURGLOCATION”)=”210 OR” OR
OBSNOW(“SURGLOCATION”)=”ASC” OR
OBSNOW(“SURGLOCATION”)=”SW Office”)
AND DOCUMENT.ASCEXCLUSIONS==””
THEN userok(“Please enter Exclusions to ASC.”) return closepage(“TRUE”)
ELSE “”
ENDIF}
Why in the second set are you using two equal signs?
I was told by my colleague to use the "==" because I was told it meant "equal to" and in this case it would mean equal to "blank"
Your colleague is correct,but in the code you posted you would want to use the double equal sign all the way through out. The way to remember is single equal sign is assignment and double equal sign is evaluation. So:
a = 5 //sets a as 5
if (a==5) then //checks if a is 5
userok("A is 5!)
else ""
endif
However, I have found that CPS/MEL is relatively lax about enforcing those rules... until it decides to enforce them. I hope this helps, but I think Joe's suggestion about the parenthesis might be even more on the right track.
all of the OR statements should have a double equal sign instead of the single. The way I understand it, the single equals sign should only be used for back end evaluations (functions), anything that gets input from an end user should be double (assigning a value to an obsterm). I could be wrong but its helped me determine when to use which.
Along with Joe's suggestion, ensure that the Page properties check box for page close is also checked. If all checks are in place, I would recommend moving the expression to the MEL window (right pane) of VFE and convert it into a watcher expression resulted to either a document variable or a temp variable to ensure that it is being fired appropriately. From there, the code is simplified for the page close (if var_name == "prompt" then userok("text") else "" endif). MEL is sneaky sneaky sometimes...