1 2 Previous Next 21 Replies Latest reply on Dec 17, 2012 10:50 AM by DavidJondreau

    What is the best work-around to simulate multi-selecting in list layout?

    jmci

      The project on which I'm currently working is to replace a legacy contact management system. The legacy system permits users to multi-select records in list view and perform actions upon those selected records. The client insists that the new system offer this capability. A simple Selected field in the Contact table wouldn't do the trick because one user's selected records would appear as selected to other users. I've come up with a solution involving a many-to-many relationship between the Contact table and the User table but it isn't very responsive and the client isn't happy. Does anybody have a solution to share?

        • 1. Re: What is the best work-around to simulate multi-selecting in list layout?
          ch0c0halic

          Use a button that adds the current record's Unique ID into a Global field and use it in a self join back to the UID. GTRR with this join will get the found set to operate on.

          • 2. Re: What is the best work-around to simulate multi-selecting in list layout?
            DavidJondreau

            I set a global variable $$marked to the ID of the record. To use it across different layouts, I use a repeating variable with a repetition coded to the layout. I use a neat custom function from Bruce Robertson called AntiFilterValues() that toggles off the ID from the list.

             

            Set Variable [ $$marked [ Get ( layoutNumber ) ;

             

            Let([

            id = TABLE::Primary_Key_ID ;

            code = Get ( LayoutNumber ) ;

            marked = $$marked[code] ;

            exists = not IsEmpty ( FilterValues ( marked ; id ) ) ;

            result = If ( exists ; AntiFilterValues ( marked ; id ) ; List ( marked ; id )

            ) ];

            result

            )

            • 3. Re: What is the best work-around to simulate multi-selecting in list layout?
              jmci

              I'm afraid I can't imagine what you're suggesting. I'd be grateful if you'd expand on your idea.

              • 4. Re: What is the best work-around to simulate multi-selecting in list layout?
                jmci

                Could you expand on the idea? How would selected records be identified on the layout?

                • 5. Re: What is the best work-around to simulate multi-selecting in list layout?
                  s

                  Create a calculated field based on the global value:

                  Case(

                  PatternCount ( $$marked ; PrimaryID & "¶" ) ; 1 ; GetAsNumber("")

                  )

                   

                  Place that field on the layout formatted as a checkbox with a value list of 1, and do not allow entry. Then you'll need a button over that field which uses David J's script above to toggle the record's id in and out of the variable.

                   

                  You don't really need the AntiFilterValues custom function to remove the record's id from the variable - you can just use the substitute function:

                  Substitute ( $$marked ; PrimaryID & "¶" ; "" )

                  • 6. Re: What is the best work-around to simulate multi-selecting in list layout?
                    jmci

                    It looks like I need to be more specific about what I'm trying to accomplish.

                     

                    My system has a Contact table. It also has a User table. At file open a script finds the User record of the logged-in account and saves the primary key field value to a global variable $$userID

                     

                    The system has a list layout based upon an occurrence of the Contact table. While in the Contact list layout, the client would like to be able to multi-select records as he can in so many other applications either by Shift+clicking contiguous records or Cmd+clicking non-contiguous records. He now understands that FileMaker list layouts don't work like that but he would still like to click on various Contact records and have them become identified as selected then perform actions on those selected records.

                     

                    As well as that, he wants the selected Contacts to be specific to the logged-in user. As a user selects a Contact he doesn't want that Contact to automatically appear to all users to be selected.

                    • 7. Re: What is the best work-around to simulate multi-selecting in list layout?
                      Mike_Mitchell

                      Do what Jimmy (ch0c0halic) has suggested above, with a slight modification.

                       

                      1) In your Users table (which, presumably, has a record for each user), define a field called SelectedContacts.

                      2) In your Contacts table, define a global field called gSelectedContacts.

                      3) As part of the user's startup script, set gSelectedContacts = SelectedContacts.

                      4) When the user clicks to select a contact, add that value to gSelectedContacts. One possible way to do this is to use List ( gSelectedContacts ; selectedID ).

                      5) When the user leaves the Contacts list, set SelectedContacts = gSelectedContacts. This will save the set of selected contacts into the user's record.

                       

                      You can use a custom function to help you. One I've found useful is on Brian Dunning's site at http://www.briandunning.com/cf/987.

                       

                      HTH

                       

                      Mike

                      • 8. Re: What is the best work-around to simulate multi-selecting in list layout?
                        DavidJondreau

                        I call this "marking" records and handle this with a button in the body part.

                         

                        The user clicks the button and the script sets a global variable of IDs to a calculation. That calculation is the current status of the global variable and either that record's ID if that ID is not in the list or removes that ID if it is in the variable. So now each user is carrying a global variable of selected IDs.

                         

                        To indicate the selected records, format the button with conditional formatting to highlight the button if that record's ID is already in the list of IDs in the variable.

                         

                        You can then script whatever you want that uses the list of IDs in the variable (find only those records, Replace[] a date field on those records, delete them, etc ).

                         

                        You can simulate "traditional" selections if you'd like with a slightly more complex script. For example you could make the whole body of list view a button and check for Get ( ActiveModifierKeys ) to run the "marking" process if the Command button is pressed. And you could capture the Get ( RecordNumber ) of the last selected ID and if Shift is pressed, grab all the IDs between the start and the end.

                         

                        By using global variables or global fields, all this is user-specific.

                        1 of 1 people found this helpful
                        • 9. Re: What is the best work-around to simulate multi-selecting in list layout?
                          DavidJondreau

                          "You don't really need the AntiFilterValues custom function to remove the record's id from the variable - you can just use the substitute function:

                          Substitute ( $$marked ; PrimaryID & "¶" ; "" )"

                           

                          Using the custom function is a pretty "clean" way. Not the only one, but your suggestion won't work under many tests.

                           

                          Consider these lists and the selected ID 234:

                           

                          List 1

                          123

                          1234

                          44499234
                          234
                          988

                          List 2

                          1
                          234
                          • 10. Re: What is the best work-around to simulate multi-selecting in list layout?
                            s

                            True enough, but that can be fixed by modifying the calcs to prepend a carriage return:

                            Substitute ( "¶" & $$marked ; "¶" & PrimaryID & "¶" ; "" )


                            Plus I try to start my auto-entered serial numbers to start at a high enough value so they all have the same number of digits (like 1000001) and then I don't have the problem you described of one number being a sub-string of another.

                            Can you think of other examples where Substitute isn't good enough?

                            Thank you.

                             

                             

                            DavidJondreau wrote:

                             

                            Using the custom function is a pretty "clean" way. Not the only one, but your suggestion won't work under many tests.

                             

                            Consider these lists and the selected ID 234:

                             

                             

                            • 11. Re: What is the best work-around to simulate multi-selecting in list layout?
                              DavidJondreau

                              Any sitiuation? Sure. I like to know how many records are currently marked. I can do that with a ValueCount() on my list. Your list though, has extra ¶ (2 extra for each time you've substituted, mixed in depending on when you've added or removed IDs).

                               

                              Why not just use a custom function? CFs are not something to be avoided.

                               

                              And "AntiFilterValues()" is pretty clear in what it's doing. You calc is going to require some mental overhead to parse it for a another developer (including perhaps a future you).

                              • 12. Re: What is the best work-around to simulate multi-selecting in list layout?
                                Fred(CH)

                                All of this is really clever but i think that the problem is : global fields or global variables are user-specific but not window-specific. That means that the result will not be correct if the user has opened many windows. Or i'm wrong ?

                                1 of 1 people found this helpful
                                • 13. Re: What is the best work-around to simulate multi-selecting in list layout?
                                  Mike_Mitchell

                                  If the user opens a second window showing the same table context and layout, then the Conditional Formatting described by David works just fine. If a different recordset or table context is shown, then the Conditional Formatting should point to a different global field or variable, and wouldn't notice the populated information.

                                   

                                  Hence, the presence of a second window really doesn't matter.

                                   

                                  Mike

                                  • 14. Re: What is the best work-around to simulate multi-selecting in list layout?
                                    DavidJondreau

                                    You sound a little disparaging at the start of your comment. Someone asked a question, answers have been given. The original question doesn't say that the answer should account for multiple windows. But if that's something you'd like, check out my original response...you can specify a repetition of a global variable. So you can link a variable to a LayoutID, LayoutName, or WindowName if you'd like ($$marked[ Code ( Get ( WindowName ) ) ].

                                     

                                    If you have multiple windows with the same name using the same layout...you may be out of luck.

                                    1 2 Previous Next