7 Replies Latest reply on May 7, 2013 9:07 AM by wrwaugh

    Displaying an icon in a portal based on a value in join table

    duncanbaker

      Hi folks

       

      Been banging my head against this wall most of the day, so time to reach out... In simple terms, I have:

      Devices - DEV (say a computer)

      Accessories - ACC (say a printer)

      ACC get assigned to DEV via a join table JDA

       

      I want to indicate if the ACC (in this case printer) is the default ACC for the device, so I have a field in JDA "Default" which is populated with "Yes" via a script if the user selects it as a default device.

       

      I have a portal based on DEV going dev>jda>acc - portal works fine for the name of the ACC etc. But I want to display an icon in the portal if the ACC is default.

       

      So I'm trying to set up a calculated container field such that if in the join, Default = Yes then container field = stored global container field and of course it's shown on the portal.

       

      I've got close with:

      Case (

      dev.JDA_JoinDeviceAccessory::Default = "Yes" ;

      dev.ZRE_z_Resources~Cartesian::Icon_DefaultPrinter_g ;

      ""
      )

       

      but this shows an icon for all instances of the printer on all DEV records. I know I've had to deal with this kind of thing before, but it's been a while and I'm stumped - might be something to do with a List function? Any help appreciated, or if I need to clarify anything, let me know.

       

      Thanks

        • 1. Re: Displaying an icon in a portal based on a value in join table
          RayCologon

          Hi Duncan,

           

          The simplest solution would be to base the portal on the join table rather than on the target entity. Then attributes of the join (in this case JDA::Default) will resolve to the appropriate "Accessory" rows in the portal.

           

          There may be a few other things to consider when making this change (eg regarding other functionality that the portal will support, such as addition and deletion of related records, sorting of content etc), so you may have a few adjustments to make to ensure it works as intended after such a change.

           

          Regards,

          Ray

          ------------------------------------------------

          R J Cologon, Ph.D.

          FileMaker Certified Developer

          Author, FileMaker Pro 10 Bible

          NightWing Enterprises, Melbourne, Australia

          Email: cologon@nightwingenterprises.com

          http://www.nightwingenterprises.com

          ------------------------------------------------

          • 2. Re: Displaying an icon in a portal based on a value in join table
            duncanbaker

            Ah that's awesomely simple. Thanks so much Ray. I changed the table the portal was based on, left the sorting as it was (based on values dev.jda.ACC which is now the next hop down), moved my calculated icon field to the join table and voila!

             

            I'm marking this as answered but have another related question as I'm curious to know what the solution is. When assigning ACC to DEV, a 'picker' is launched which is a new window based on DEV and a portal showing dev.org.ACC (when ACC records are created they belong to an organization and therefore this portal only shows ACC belonging to the ORG in question). You click the portal record and a script creates the join between the DEV and ACC. This window currently shows this default icon (dev.org.acc.jda::icon) wherever the icon is present, whether the ACC is assigned to DEV or not. If I only wanted to show the icon for the current device even though I'm viewing ACC records for the whole ORG, have I created myself a monster headache? I've tried a couple things to no avail of course. I'll keep experimenting in the meantime, but if the explanation above makes sense and you/anyone else has any ideas, I'd be grateful.

             

            I'll no doubt be back as the project proceeds. Thanks again.

            • 3. Re: Displaying an icon in a portal based on a value in join table
              RayCologon

              Hi Duncan,

               

              The accessory 'picker' window you've described is for the purpose (as I understand it) of adding an accessory to those listed for the selected device. So, presumbly it would make sense for the user to be presented with a filtered portal list of only those available accessories that have not already been associated with the selected device (no point in adding an accessory if it's already listed for the device). In which case, none of the filtered list of accessories could be default (yet) for the current device since they aren't yet listed accessories for the device - I'm assuming you need to add an accessory before indicating that it is default, no?

               

              If the guesses/assumptions I'm making here are on point, then the simplest answer would be to omit the default icon/field from the portal in the picker window, as it would not be helpful or meaningful in that context. Or, at any rate, if there is a meaning or purpose to having the default icon (or, forf that matter, the already-listed accessories for the device) show in the picker portal, I'm not seeing what it is.

               

              That said, if for some reason you do need to show current accessories and to indicate which are default for the current DEV, there are a couple of ways to do so. One would be to use conditional formatting (which can reference the parent record context as well as the portal row context, to resolve the display condition with respect to the current device) rather than relationships to show/hide the default icons within the picker portal rows. Another would be to modify the relationship between the portal context (dev.org.ACC) and the dev.org.acc.jda join table to add a predicate which filters based on the selected DEV record. So that would become a multi-predicate with the addition of a global field (gDeviceID) in the ACC table into which the process that invokes the picker window (trigger or user-initiated script) would be required to write the ID of the current device record.

               

              Regards,

              Ray

              ------------------------------------------------

              R J Cologon, Ph.D.

              FileMaker Certified Developer

              Author, FileMaker Pro 10 Bible

              NightWing Enterprises, Melbourne, Australia

              Email: cologon@nightwingenterprises.com

              http://www.nightwingenterprises.com

              ------------------------------------------------

              • 4. Re: Displaying an icon in a portal based on a value in join table
                duncanbaker

                Sorry it's taken so long to respond to this. Just wanted to note that the multi predicate solution was the way to go in this instance. Thanks so much for the pointers in getting me back on track with this. I'll be back with other questions at some point soon no doubt!

                • 5. Re: Displaying an icon in a portal based on a value in join table
                  wrwaugh

                  Ray,

                   

                  I would like to jump in here with a question if I may.  I have a very similar problem and I am not quite understanding your solution here.  Using the same tables as  in the example above of

                  Devices - DEV (say a computer)

                  Accessories - ACC (say a printer)

                  ACC get assigned to DEV via a join table JDA

                   

                   

                  I show two portals on the screen... one portal is from JDA showing Accessories added to Device #1

                  The second Portal is a list of all Accessories.

                   

                  A script attached to a button in each portal row of Accessories creates a new record in JDA and populates it with the Primary Keys of the Accessory selcted and the Device in question.

                   

                  I want the selected accessory to no longer show in the portal of accessories once it is selected (as each device can only get one of each accessory).

                   

                  I would like to do this by filtering the accessory portal to show only records not associated with the JDA in question,   because, for the next device I need all accessories to be available (even if they have been 'assigned' to another device).

                   

                  I am unclear how to filter the Accessory portal to make them not show once picked.  If I try to filter by a simple "Show records in the portal only if the ACC::ACC_PK ≠ JDA::ACC_FK" only the first accessory selected is filtered out.

                   

                  Can you explain just how to get my desired result?  I feel like I am on merry-go-round that just won't stop.

                  • 6. Re: Displaying an icon in a portal based on a value in join table
                    RayCologon

                    Hi wrwaugh,

                     

                    As I understand what you're saying, if you're using a filter calculation defined via the Portal Setup, you should be able to use a calculation such as:

                     

                    not PatternCount(List(JDA::ACC_FK); ACC::ACC_PK))

                     

                    ...which uses a logic akin to your attempt with ACC::ACC_PK ≠ JDA::ACC_FK, but compares the value in ACC::ACC_PK with all of the values retrieved from JDA::ACC_FK (via the List( ) function), not just the first.

                     

                    Regards,

                    Ray

                    ------------------------------------------------

                    R J Cologon, Ph.D.

                    FileMaker Certified Developer

                    Author, FileMaker Pro 10 Bible

                    NightWing Enterprises, Melbourne, Australia

                    Email: cologon@nightwingenterprises.com

                    http://www.nightwingenterprises.com

                    ------------------------------------------------

                    • 7. Re: Displaying an icon in a portal based on a value in join table
                      wrwaugh

                      As always, You are the best Ray!.

                       

                      Thank you for your accurate and very prompt reply!