6 Replies Latest reply on Dec 8, 2009 11:17 AM by jenee

    Script to check a checkbox

    jenee

      Title

      Script to check a checkbox

      Post

      Is it possible to write a script that (1) performs a find on specific criteria and then (2) checks a certain value in a checkbox on all found records?

       

      I've only created basic scripts before, and I've browsed through the help files, and searched online and I'm beginning to think that this particular script is just not possible. Any help would be appreciated!

       

      I'm running FileMaker Pro 8 on Windows XP.

        • 1. Re: Script to check a checkbox
          ninja
            

          Howdy jenee,

           

          I'm also on FMP8 (XP)

           

          Assume:

          field for search = "Findfeild"

          Criteria = "this"

          checkbox value = "Active"

          Checkbox field = "Status"

           

          Script:

          Enter find mode

          Setfield [ Table::Findfield ; "this" ]

          Set ErrorCapture [on] ##optional

          Perform Find

          Replace Field Contents [ Table::Status ; "Active" ]

           

          When changing large blocks of records, pay extra special attention to having backups.

           

          Note: This task isn't very hard to do manually...if you are doing this on a regular basis, think about why this is so.  There are some good reasons to do this often (like archiving blocks of invoices which are 6months old, etc.), but make sure you think it through.

           

          Enjoy the day!

          • 2. Re: Script to check a checkbox
            jenee
              

            Thanks -that worked, more or less. The problem I ran into was that it was asking me what to replace the current contents with - either the current contents, an incrimental serial number or a calculuated value.  Since my current contents were blank, that option was out; I wanted the same value ("no") for all boxes, so an incrimental number was out, and I couldn't figure out how to calculate the value "no"

             

            So I used your script, but before I run it, I will have to check "no" on the first record of my found set, and then I can use the "current contents" option to check the rest of them. 

            • 3. Re: Script to check a checkbox
              ninja
                

              Howdy jenee,

               

              You calculate the word "no" by using the quotation marks around the word.

               

              For the replace field contents, choose calculation and a calc popup window will appear.  In the big white box, type

               

              "no"

               

              with the quotes.  Now you wont have to modify the first record and then the rest.  Do them all at once with the calculation option.

              • 4. Re: Script to check a checkbox
                jenee
                   Wow, that was too easy of a solution. Three cheers to over-thinking!
                • 5. Re: Script to check a checkbox
                  philmodjunk
                    

                  Note of caution: Replace Field Contents can be a bit dangerous if your file is shared between two or more users. If user 1 clicks in one of the fields that user 2 wants to update with Replace Field contents, they have locked the record and this will prevent Replace Field Contents from changing this one record. User 2 has no way to know this and if they perform a replace field contents operation, filemaker will report that a record was not updated but will not tell you WHICH record was locked by the other user. Thus, you should only use Replace field contents...

                  1. On single user files or
                  2. After hours when there are no other users accessing the DB or
                  3. On records that are somehow made unavailable to other users prior to performing the replace (Difficult to do in 100% foolproof manner).
                  • 6. Re: Script to check a checkbox
                    jenee
                       Thanks for the warning PhilMod -I'm the only one who uses this particular database, so that won't be an issue for me!