5 Replies Latest reply on Dec 6, 2011 11:36 AM by philmodjunk

    Selecting individual records with checkbox from a portal list

    VenturaDon

      Title

      Selecting individual records with checkbox from a portal list

      Post

      I'm a newbie using FM 11 Advanced. Have spent hours studying checkboxes, scripts, portals, etc, in the forums/knowledge base and thought it should be "straightforward" to create a script that would allow a user to check checkboxes from a found set of records in a portal, but I need help - can't figure it out.

      I've created a value list "Select Record" with custom value of 1. I have a layout with a TO portal ("Data Records2") and field ("Street") and the checkbox. Following PhilModJunk's advice on an old post, I've got 2 text fields on the layout (one with a checkbox) and can toggle the "1" in the blank text field on and off, but can't figure out how to use that info to select records in the portal. I want to be able to check some records then select a button ("Select Records") to only show those records in the portal list. Thanks all!

        • 1. Re: Selecting individual records with checkbox from a portal list
          philmodjunk

          So first you see all related records in the portal and then, after clicking check boxes, you want the same portal to show only the selected ones?

          Interesting concept.

          You'll need a portal filter that filters for the selected items, but which can also be turned "on" or "off".

          Try this portal filter expression:

          Not $$FilterOn or data Records 2::checkboxField

          Set your button to turn on/off the filter to be:

          Set Variable [$$FilterOn ; value: Not ( $$FilterOn ) ]

          Refresh Window [Flush cached join results]

          If the portal is not filtered, clicking your button will turn the filter on. If it is filtered, clicking the button will turn it off. When you first open the file, the filter will be off. And you can try this without the window refresh step if you want to experiment. Refresh Window [flush cached join results] is a step best avoided, but I think you'll need it here to get the filtered portal to update.

          • 2. Re: Selecting individual records with checkbox from a portal list
            VenturaDon

            Thanks PhilModJunk - your comment that "Refresh Window [Flush cached join results]" is a step best avoided gives me pause... is there a more elegant solution? I'm trying to copy the idea of the attached screenshot; perhaps their solution is more appropriate. A user clicks on the checkboxes (in any order - or they can select the checkbox at the top for all records) then the user clicks a button "Remove all unchecked". Thoughts? Thanks!

            • 3. Re: Selecting individual records with checkbox from a portal list
              philmodjunk

              What you show in the screen shot could be a list or table view. The button could then perform a script that uses constrain found set to filter out all non selected records from the found set.

              PS. is this for a database that will have more than one user making these selections at the same time? If so, each user will see the other's selections and des-selections resulting in user frustration and confusion. There's another approach to use in cases where this is a multi-user system.

              • 4. Re: Selecting individual records with checkbox from a portal list
                VenturaDon

                Hi PhilModJunk - Yes, I was striving for a list view idea and was originally thinking of a script that would do a constrain but didn't know how to approach it with the checkbox. And also yes, it will ultimately be for a multi-user system. Could you recommend a script for a constrain method? I think that's the right approach in this scenario... Thanks for your expertise with FM and patience with us newbies!!

                • 5. Re: Selecting individual records with checkbox from a portal list
                  philmodjunk

                  Enter Find Mode [] //clear the pause check  box
                  Set Field [Yourtable::yourcheckboxfield ; 1 ]
                  constrain found set[]

                  The problem with this approach in a multi-user environment is that if two users are clicking check boxes on their respecitive client machines at the same time, their choices could easily interfere with each other.

                  To avoid this, you'd change your check box field into a button. The button's script would add/remove the records serial number from a list of selected ID's stored in either a global field or a global variable. Conditional formatting on the button can indicate whether a given record is selected. The button can even be an X or a tick mark character that appears/disappears when clicked.

                  Then you'd use a Constrain Found set script or a go to related records step to reduce the listed records to just those listed in the global field/variable. The 'global list' method works in a multi-user environment because changes to variables and global fields are not visible to other users.