6 Replies Latest reply on Jan 2, 2013 11:44 AM by BobGossom

    Detecting empty fields

    laguna92651

      I want to do a Delete All Selected records script by ssetting a Select checkbo, which I think should be easy enough, but before I do the Find and Delete I want to be sure there is a Select field selected in at least one record of the displayed view, if not I want to display a message "Please select records to delete", Want would be the logic to go through the displayed list to determine that at least one record is selected?

       

      Thanks

        • 1. Re: Detecting empty fields
          timwhisenant

          Hi,

           

          Use an If statement like,  If( Get(FoundCount)) {your delete code here} EndIf

           

          Get(FoundCount) will be true if there are records and false if no records are in the found set.

           

           

          HTH,

          Tim

          • 2. Re: Detecting empty fields
            laguna92651

            There will be records, what I want to test for is whether any of the records are selected for deletion, checkbox field called Select. If no records are selected, then pop up message reminding user to select records.

            • 3. Re: Detecting empty fields
              timwhisenant

              Script a find based on the value in the checkbox field.

              If you need to preserve the found set, call a new window to do the find in, then close the new window when done and your preserved set will be waiting, without the deleted records, of course. You probably will need to do a refresh, I have not tested this.

               

              HTH

              Tim

              • 4. Re: Detecting empty fields
                laguna92651

                Not quite sure of the process here, I'm new to FM. I can put the same data set in a second window and manipulate it there, then return to the first window and have the new results, how would I do that. Where does the checking take place on whether there are records selected?

                • 5. Re: Detecting empty fields
                  vidkid98

                  here's pseudo code version of Iaguna92651's reply

                   

                  0. (assume user has selecte some records for deletion by clicking in the checkbox)

                  1. open a new window

                  2. search for records that have the checkbox you defined selected (usually search on value = 1 for a checkbox that's checked)

                  3. if(get(foundcount) > 0

                  4.  then delete current records

                  5. end if

                  6. close window

                   

                  The result will be checked records no longer are in the list in the existing window, these have been deleted.

                  • 6. Re: Detecting empty fields
                    BobGossom

                    Hi,

                     

                    One thing to think very carefully about is multi-user issues. If two people are marking records at the same time, when you find all of the marked records for User A, it could easily find the records being checked by User B - and deleting them before they were ready.

                     

                    Another "gotcha" in the process is what happens if someone marks records to be deleted, but then doesn't complete the process? They could exit FMP and leave these records marked for deletion. The next person to mark and delete records would end up deleting more than they expected.


                    One solution would be to control access to this process so that only one person could be deleting records at a time. If you do this, you can just use a value of "1" for the checkbox, and then get a total of it to detect whether any records had been checked or not. You could prevent navigation away from the layout if they mark records, but don't complete the delete. If you do control access to this process, and limit it to just one at a time, you could clear any previous marks each time someone starts.

                     

                    If you want to keep it mult-user, you'll need a way to distinguish between the checkmarks made my user "A"and user "B". The easiest way to do this is to keep a user/session log. Then the checkmark would be linked to their user/session ID and you can find just their records. Post back if you need more info on this.

                     

                    Bob Gossom