7 Replies Latest reply on Oct 12, 2009 10:23 AM by philmodjunk

    Checkbox script action for multiple records.

    sparky27

      Title

      Checkbox script action for multiple records.

      Post

      Hi, I have a single check box on all of my records. I want to be able to have the user click on a button on anyone of the forms to perform the following action: Check all records to see which records have the check box checked and then un-check the checkbox. Note, that the checkbox is not global because i do not want the user to check the box on one record and then this cause all records to be selected. I cannot work out how to do this in the scripts. Anyone have any ideas? Sparky27.

        • 1. Re: Checkbox script action for multiple records.
          Sorbsbuster
            

          Hi sparky27,

           

          In essence, it's straighforward (unless I've missed the point.  If so,: sorry.)

           

          The button you mention will run a script that:

          - goes into Find Mode

          - sets the search criteria to be 'Your CheckBox = Checked'

          - Performs that Find

          - Goes to the field 'CheckBox'

          - Does a 'Replace with current contents' ('...without dialogue')

           

           

          You could make it neater with a check that you don't get  no records found.

           

          I hope that helps - if it doesn't, ask again and I'll send you the actual script.

           

          Alan.

           

          PS: This is it in more detail (# denotes a comment line):

           

          • #Go to a layout with the CheckBox field on it
          • Go to Layout [ The Layout That I Want ]
          • #Set the search criterion to be CheckBox field = 'Yes' (or whatever is the Checked Value)
          • Set Error Capture [ On ]
          • Perform Find [ Specified Find Requests: Find Records; Criteria: CheckBox: “"Yes"” ] [ Restore ]
          • #If no records are found, explain to the user
          • If [ Get (FoundCount ) = 0 ]
          • Show Custom Dialog [ Title: "No Checked Records"; Message: "No records have that box checked, so no records have been changed"; Buttons: “OK” ]
          • Exit Script [ ]
          • End If
          • #...otherwise replace the CheckBox Field contents with a 'calculated Blank'
          • Replace Field Contents [ CheckBox; Replace with calculation: "" ] [ No dialog ]
          • #...and finish tidily
          • Go to Record/Request/Page [ First ]
          • Commit Records/Requests [ Skip data entry validation; No dialog ]
          • 2. Re: Checkbox script action for multiple records.
            sparky27
              

            Hi Alan,

             

            I tried to complete this task the more elegant and tidy way that you have suggested, and i tried to complete this a simple way but i could not get either working.

             

            First i tried the more elegant way:

             

            Go to Layout [original  layout]

            Of [MY DATABASE: sort=True]

            Set Error Capture [on]

            Perform Find Find[Restore]

            Set Variable[$FoundCheckBoxesSetToTrueCount; Value:2]

            If.......

             

            But i couldn't set the counter variable to later check if any check boxes across all records are counted to then decide whether to show the error message stating that none are selected or to perform the action required i.e. un-check all selected.

             

            I then tried the simpler way:

             

            If [PRODUCT DATABASE::sort = True]

            Perform Find {Restore]

            End if

            Replace Field Contents [PMY DATABASE:: sort= false]

             

            Please could you post the script?

             

            Thank you for your help.

             

            sparky27.

            • 3. Re: Checkbox script action for multiple records.
              sparky27
                

              Sorry, in  the last message the following line:

              Set Variable[$FoundCheckBoxesSetToTrueCount; Value:2]

               

               

              should have been

              Set Variable[$FoundCheckBoxesSetToTrueCount; greater than 0]

               

              sparky27.

               

              • 4. Re: Checkbox script action for multiple records.
                Sorbsbuster
                  

                Sorry, sparky27, you're going a bit fast for me.

                 

                Can we break this down into simpler steps for me, please?

                 - I assume that the field you are checking for is called 'sort'.

                - If that is the case, just go into 'Find' mode, and check the checkbox for 'sort'

                - Do that find.  (hopefully it will find some records!  No matter, though, if it doesn't.)

                - Now go into Scriptmaker and create a new script.  Call it 'Find Checked Records'.

                - Enter one script step into it: 'Perform Find'. When you click the 'Specify find request' box you will see that it has pre=set the 'Find' you just did.  Leave it as it is.

                - Exit, and save the script.

                 

                If you run that script, you should find that it consistently finds the records you want.

                 

                Now, you want to replace the contents of a field (not sure what it is, but you know, obviously) in all the records that you've found.

                 

                - Open the script again.

                - Add the step 'Replace Field Contents'

                - Set the options as follows :

                - 'Specify Target Field'- set to be the field you want to clear

                - 'Specify' - set to 'Calculated result', and make it '""' (a pair of emptydoubvle-inverted commas, meaning <blank>

                - ...and on the lower left side, check to 'Perform without dialogue'.

                 

                This will then find all the records you want to change, and set the field (that you want) to be blank.

                 

                We can worry later about what happens if the first search returns no found records.

                 

                Sorry to be so slow, but sometimes it takes me a while to catch up when the only explanations are by text.  But at the end of this your script should only have two script steps:

                 

                - Perform Find

                - Replace Field Contents

                 

                 

                It will be easier for me to help you from that starting position.

                 

                Alan.

                 

                • 5. Re: Checkbox script action for multiple records.
                  sparky27
                    

                  Hi Alan, 

                  I have now managed to get this working. I am very new to FileMaker and so have had a little difficulty in understating some of the things that you mentioned in your post. I ended up with the following: 

                  Perform Find [Restore]

                  Replace Field Contents [No dialog; PRODUCT DATABASE::SORT; ‘’’’]

                  Show All Records 

                   

                  My check box that I was trying to check if was selected and then unselect any records that has this checked. If I did not add the line ‘Show All Records’ to the script then after when I had searched all records and ‘un-checked’ the checkbox I was left with just the records that had been changed out of all of the records that I started with – adding that line meant that I finished my actions and was re-presented with all of the records again that I started with. Thank you for all of your help on this Alan, great help. 

                   

                  Sparky27

                  • 6. Re: Checkbox script action for multiple records.
                    HWRE
                      

                    I have Filemaker Pro 9 Advance.  The following script works on my computer Windows XP but not on IWP anyone have an answer or work arounds??

                     

                  • #Go to a layout with the CheckBox field on it
                  • Go to Layout [ The Layout That I Want ]
                  • #Set the search criterion to be CheckBox field = 'Yes' (or whatever is the Checked Value)
                  • Set Error Capture [ On ]
                  • Perform Find [ Specified Find Requests: Find Records; Criteria: CheckBox: “"Yes"” ] [ Restore ]
                  • #If no records are found, explain to the user
                  • If [ Get (FoundCount ) = 0 ]
                  • Show Custom Dialog [ Title: "No Checked Records"; Message: "No records have that box checked, so no records have been changed"; Buttons: “OK” ]
                  • Exit Script [ ]
                  • End If
                  • #...otherwise replace the CheckBox Field contents with a 'calculated Blank'
                  • Replace Field Contents [ CheckBox; Replace with calculation: "" ] [ No dialog ]
                  • #...and finish tidily
                  • Go to Record/Request/Page [ First ]
                  • Commit Records/Requests [ Skip data entry validation; No dialog ]
                  •  

                    • 7. Re: Checkbox script action for multiple records.
                      philmodjunk
                         Show custom dialog is not compatible with web publishing. You'll need to switch to a dedicated layout for communicating this info to the user. To see what steps are compatible in FMP 10, Open the script editor and select Web Publishing from the Show Compatibility drop down in the lower left corner.