4 Replies Latest reply on Jan 23, 2013 12:06 PM by JCrawford

    Conditional field access



      Conditional field access



           I am preparing a medical questionnaire administered by computer. If a client has a health condition, he or she is expected to enter some details. If not, the tab control should skip to the next question. Example:

           Field 1: Do you have diabetes?

           Drop Down Value List: Yes No

           If Field 1 is answered with "Yes," the tab control should advance to Field 2, where the user is supposed to supply details about their diabetic condition.

           If Field1 is answered with "No," the tab control should advance to Field 3 and skip Field 2 entirely.

           The health survey is 19 pages long so I have to write this script several dozen times. I would like a one-size-fits-all script trigger, but I can't figure out how to do this. Here is my futile attempt so far. This script trigger is activated upon Exit from the Yes/No field. It is supposed to jump from Field 1 to Field 3 but it doesn't.


           SetVariable($FieldName; Value:Get(ActiveFieldName))

           If ($FieldName="No")

             Go to Next Field

             Go to Next Field

           End If

           Exit Script


           Thank you for any help.

        • 1. Re: Conditional field access

               Get ( activeFieldName ) returns the name of the field. If you put No In a field named "Diabetes". The function returns "Diabetes", not "No".

               You can use something like this:

               If [ Get ( ActiveFieldContents ) = "No" ]
                 Go To Next Field
                 Go To Next Field
                 Exit Script [False]
               End IF

               The exit script step is needed to cancel out the user action exiting the field or it will be processed after the scritp completes and put the cursor back into the next field where you don't want it to be.


                    The health survey is 19 pages long

               I strongly suggest that you redesign your survey so that each question and each response is a different record (responses in one table, questions in another). This will greatly simplify the design of your layout and also greatly simplify any statistical reporting that you do from these surveys.

               See this thread for some ideas on how to set up a FileMaker survey: Need aid on generating a report from a survey layout.


          • 2. Re: Conditional field access

                 Thanks - I should have looked harder for a good get function. I will look at the survey recommendations - of course you tell me now that the 19 pages of questions and field responses are written! I'm on the final leg of it - tab order. But I will look at it as this is the third such project I've done lately. I felt each survey should be a single record - for a single client who may take the survey multiple times ... pre, mid, and post treatment.


                 Again thanx!

            • 3. Re: Conditional field access

                   You can use on field1 a script trigger OnObjectModify to perform the following script

                   If [Field1="No"]
                     Go to Next Field

                   You only need 1 Go to Next Field because FM will exits the first field when the script trigger fires, so if yes it goes to next field in line and if No then it goes to 2nd field in line.  Your tab order will effect this also.

              • 4. Re: Conditional field access

                     I want to comment on both suggestions and provide a third alternative for other readers.

                     S - "On Object Modify" helped. Thank you. I did not use your script because I wanted one script that could be used on many different fields where tab order is conditional upon the user's response. Your script asks for a specific field name and while it works, it can't be used on other fields.

                     Phil - a couple things came to light when testing your solution against the settings I was using, and for the benefit of other readers I am submitting these additional clarifications.

                First, use either Popup Menu or Radio Buttons. I was using a drop down list but that option will advance the cursor to next field in the tab order regardless of the value of that field. A checkbox isn't any good either as it will allow multiple responses.

                Second, launch the script trigger "On Object Modify" rather than "On Object Exit." The latter won't advance the cursor at all if a popup menu or radio button is used.

                Third, the script should include steps for any value entered. If it does not, it will properly skip a field if the answer is "No" but will not advance the cursor at all if the answer is "Yes" or "Maybe" or "I Don't Know."

                So, with your help, here is a third solution, and it does work properly. Use this script trigger "On Object Modify" and use popup menu or radio button set option.


                     Set Variable($No; Value:Get(ActiveFieldContents))


                        Go to Next Field

                        Go to Next Field

                        Exit Script


                     Go to Next Field

                     Exit Script