4 Replies Latest reply on Feb 19, 2013 9:25 AM by philmodjunk

    Can you setup a confirmation question before a script is run?

    vincel

      Title

      Can you setup a confirmation question before a script is run?

      Post

           I've setup a script that inserts the values from the last visited record on certain fields.  The problem is that it over-writes anything that may be in the field already entered.   The pupose is to enter these fields on a new record, but at times the Ipad users forget to first create a new record.   So they run the script and overwrite their current record fields.  

           Is there a way to either - 

           As a confirmation question once the script is run where the user has to hit yes or no before the script is run

           OR

           modify the script that it will not overwrite existing field data?

           Also - I've noticed when running this script that it does not always run as expected.  At times it pulls the data from the last record visited.  But sometimes it is just pulling the data from the last record in the database.   Also at times it hangs up and instead of working it just moves the cursor into one of the last fields in that layout and i have to delete that record and create a new.   Any ideas?

        • 1. Re: Can you setup a confirmation question before a script is run?
          schamblee

               You can do both.  You can use a custom dialog box to get confirmation and you can also use a if empty statement before you set the value into the field.  You can also create your own new record button that performs the conformation, then runs the script and validate the field is empty.

          • 2. Re: Can you setup a confirmation question before a script is run?
            philmodjunk

                 Both options are possible.

                 To ask for confirmation:

                 Show Custom Dialog [ "Do you really want to do this?"]
                 If [ Get ( LastMessageChoice) = 1 // Button 1, OK was clicked ]
                   //Put the rest of your script here
                 End IF

                 To check to see if a field has data in it before modifying it:

                 IF [ IsEmpty (Table::Field ) ]
                    //Put steps to modify the field here
                 End IF

                 You can even combine the two methods by using Not Isempty and then asking for confirmation before modifying that field.

                 With regards to your last question, am I correct that you are using the "insert from last visited" script step?

                 If so, which record was 'last visited' can be a bit fuzzy in FileMaker. It's defined as the "last active record" and this is a record that you opened for editing--usually by modifying a value. There may not be a "last active record" at the time the user performs the script or it may be a different record than they expected as they may have edited record 1, navigated to record 2 and then created a new record, only to find that the script copied data from Record 1, not record 2.

                 To get better results you may want to create a new table occurrence of your layout's table and devise a self join that consistently references the "last record" and then you can control what will be selected as the Last Record.

            • 3. Re: Can you setup a confirmation question before a script is run?
              vincel

                    

                   With regards to your last question, am I correct that you are using the "insert from last visited" script step?

                   If so, which record was 'last visited' can be a bit fuzzy in FileMaker. It's defined as the "last active record" and this is a record that you opened for editing--usually by modifying a value. There may not be a "last active record" at the time the user performs the script or it may be a different record than they expected as they may have edited record 1, navigated to record 2 and then created a new record, only to find that the script copied data from Record 1, not record 2.

                   To get better results you may want to create a new table occurrence of your layout's table and devise a self join that consistently references the "last record" and then you can control what will be selected as the Last Record.

                    

                   Yes that is correct...using that script.   Could you help or point me to another site that may help with creating the table occurrence ?

              • 4. Re: Can you setup a confirmation question before a script is run?
                philmodjunk

                     To create a new table occurrence for an existing table:

                     In Manage | Database | relationships, make a new table occurrence of YourTable by clicking it and then clicking the duplicate button (2 green plus signs). You can double click the new occurrence box to get a dialog to appear where you can rename the new occurrence box.

                     We have not duplicated a table. Instead, this is a new reference to the same table already present in your database.

                     To learn more about table occurrences and how to make use of them: Tutorial: What are Table Occurrences?