5 Replies Latest reply on Jul 18, 2013 7:29 AM by Annette

    Script Help

    Annette

      Title

      Script Help

      Post

           Hello,

           was hoping to get some help with what i thought was a simple script that isn't working.

           On a layout I have various fields, name, data of bith, address, etc. 

           I'm trying to build a script to make sure key fields are completed and not left blank, key fields being first, last name and date of birth.  I was trying to build it in steps since I still am learning.  Tried starting with checking on DOB.  I have the following script on button, if the data of birth field is blank i want it to prompt to complete it, if it's not blank then proceed to layout.  It's prompting me when the dob is blank but then once i fill it in when i click button again to move on it doesn't go to the layout. 

      SetVariable [$NoData; Value;""]

      If [IsEmpty (client info::DOB)]

      Set variable [$NoData; Value: $NoData & "DOB MIssing"]

      If [IsEmpty ($NoData)]

      Go to layout [MainMenu]

      else

      show custom dialog ["Enter DOB"; "Client date of birth is required"]

      End if

      End if

           What am I doing wrong that it won't move to the layout once I have filled in the empty field??  Once I get it right I want to add more if statements to check for a couple of other blank fields but wanted to make sure I got one to work first.

           Thanks for the help!

        • 1. Re: Script Help
          ninja

               1. Making sure data is filled in is usually done by field validation ("Not Empty") rather than by script.

               2. step 4 of your script is that if the field is empty (a bad thing) you go to a different layout...why would you do this?

               3. Your custom dialog asks for DOB only if there already is one...it is on the other side of the "else".

               4. If DOB is empty, you set a variable to a value that includes the emptiness...what would that accomplish?

               5. you set the variable...then do nothing with it.  Why are you trapping the words and the emptiness?  What are you trying to accomplish?

                

               I would recommend that you handle this through field validation (In field properties dilaog box).

                

          • 2. Re: Script Help
            Annette

                 I am not using field validation as it prompts you then every time you go in another field or section of the layout if it is blank.  I am going to put this script on the layout exit once I get it to work properly.  It will allow me to check multiple fields without getting prompted every single click around the layout as happens with field validation.

                 Step 4 is if the variable is empty not a field, which I want it to be...so dont see that as a bad thing.  Basically if the DOB field is empty it sets the variable $NoData to have text in it.  then later steps look and see if there ended up being text in the variable and shows custom dialog to fill in the empty field, if the field wasn't empty, no text gets pasted into that variable, which then allows you to go to the layout.  That's the idea anyway. 

            • 3. Re: Script Help
              Annette

                   I've sorted it, i needed to move the end if up after the first if.....works like a charm now. 

              • 4. Re: Script Help
                philmodjunk

                     I'd write such a script like this:

                     If [Isempty ( Table::Field1 ) ]
                        Show Custom Dialog [ "Field 1 is missing a required value" }
                        Exit Script[]
                     End If

                     If [ IsEmpty ( Table::field2 ) ]
                         Show Custom dialog
                         Exit Script[]
                     End If

                     Go to layout ["main...

                     That makes it very easy to add/remove change your validation tests on each field.

                • 5. Re: Script Help
                  Annette

                       Thanks Phil, I suppose there is multiple ways to do it alright, here is what I ended up with, it then gives me one nice little dialog box with a list of the empty fields in the one dialog box.....