9 Replies Latest reply on Dec 19, 2013 8:35 AM by philmodjunk

    Need a Portal to behave like a checkbox set

    shae1725

      Title

      Need a Portal to behave like a checkbox set

      Post

           I have a check box set on my layout.

           I have a field which lists the values of each check which filters a portal! It all works fine except the checkbox looks a bit basic and I would like to have other fields related to the checkboxes values displayed!

           I would like to build a portal which would behave like a checkbox.

           I intend to place a button on each portal line which will add a value to the list and remove as needed. I have no idea how to build a calculation for the button for adding or removing values

           Any help would be appreciated

        • 1. Re: Need a Portal to behave like a checkbox set
          philmodjunk

               Take a look at the "check boxes" layout in this demo file on many to many relationships: https://www.dropbox.com/s/oyir7cs0yxmbn6i/ManyToManywDemoWExtras.fp7

               What looks like check boxes are actually a rectangle object and the letter X. Conditional formatting hides/reveals the X by changing the font size. In FileMaker 13, I'd probably use the new "hide when" feature to do the same or specify "no color" for the font color.

               The two objects are buttons that perform a script to select or clear a selection. In this demo file, the selecting a value creates a record in a related table, but you could also have your scripts update a list of values in a field or variable instead by appending/deleting the selected value.

          • 2. Re: Need a Portal to behave like a checkbox set
            shae1725

                 Thanks Phil

                  

                 I have set the add value  button on my portal with a small script (see photo) with a button hide calculation taken from your example script

                  

                 ValueCount ( FilterValues ( List ( MountPalette_FD.fp12::ColorIDList) ; Portal_ColorGroupID.fp12::pkColorID ) )

                 This all works ok but I have no idea on how to set the remove a value button!  I cant work out how you did it in your examples.

            • 3. Re: Need a Portal to behave like a checkbox set
              philmodjunk

                   In the example file, the database is creating or deleting records from a join table. But what you have here can be made to work.

                   If [ IsEmpty( FilterValues ( MountPalette_FD.fp12::ColorIDList) ; Portal_ColorGroupID.fp12::pkColorID ) ) // value is not selected ]
                       Set Field [ MountPalette_FD.fp12::ColorIDList ; List ( MountPalette_FD.fp12::ColorIDList ; Portal_ColorGroupID.fp12::pkColorID ) ]
                   Else
                       Set Field [ MountPalette_FD.fp12::ColorIDList ; //see calc below ]
                   End If

                   Let ( [ TheList = ¶ & MountPalette_FD.fp12::ColorIDList & ¶ ;
                              TheList = Substitute ( MountPalette_FD.fp12::ColorIDList ; ¶ & Portal_ColorGroupID.fp12::pkColorID & ¶ ; ¶ )
                            ];
                              Middle ( TheList ; 2 ; Length (TheList ) - 2 )
                          ) // Let

              • 4. Re: Need a Portal to behave like a checkbox set
                shae1725

                     Many Thanks Phil

                     Working Great :)

                     would I still keep  List(ColorIDList) in the fields calculation? its working without it at the minute.

                     As far as the calculation for the delete button hide function would it be much the same as the add button calculation I mentioned in my last post?

                      

                      

                      

                • 5. Re: Need a Portal to behave like a checkbox set
                  philmodjunk

                       List ( SingleField )  makes no change to your data, it's the same as just using SIngleField in place of it.

                       Thus, you don't have to remove it, but it unnecessarily complicates your calculation.

                  • 6. Re: Need a Portal to behave like a checkbox set
                    shae1725

                         Ok! yet again many thanks

                         I worked out how to hide the delete button

                         Was pretty obvious once I broke down your script

                         IsEmpty( FilterValues ( MountPalette_FD.fp12::ColorIDList) ; Portal_ColorGroupID.fp12::pkColorID )

                    • 7. Re: Need a Portal to behave like a checkbox set
                      philmodjunk

                           Yes, but it's:

                           IsEmpty( FilterValues ( MountPalette_FD.fp12::ColorIDList ; Portal_ColorGroupID.fp12::pkColorID ) )wink

                      • 8. Re: Need a Portal to behave like a checkbox set
                        shae1725

                              

                             I noticed odd behaviour when removing from the ColorIDList

                             I can remove more than one colorID at a time

                              

                             If I add ColorID 1 and ColorID  2 then remove  ColorID 1 .....  both 1 and 2 are removed from ColorIDList

                             If I repeat the above but  I remove ColorID 2 then ColorID 1 will stay in list.

                              

                              

                        • 9. Re: Need a Portal to behave like a checkbox set
                          philmodjunk

                               I didn't have this expression set up correctly:

                               Let ( [ TheList = ¶ & MountPalette_FD.fp12::ColorIDList & ¶ ;
                                          TheList = Substitute ( TheList ; ¶ & Portal_ColorGroupID.fp12::pkColorID & ¶ ; ¶ )
                                        ];
                                          Middle ( TheList ; 2 ; Length (TheList ) - 2 )
                                      ) // Let