14 Replies Latest reply on May 1, 2012 11:15 PM by m.bodily.consulting

    Using a popup menu to retrieve record

    m.bodily.consulting

      I want to use a popup menu to get values from a field called Patrons. By using this pop up menu I wanted to bring up the patron record. Do popup menu's function like this?

        • 1. Re: Using a popup menu to retrieve record
          Stephen Huston

          You can do this by attaching a script trigger to the field with the popup menu in it, set it to trigger onObjectModify.

           

          Then attach a script that grabs the info from the field and performs the desired search and any needed adjustment or change of layouts.

          • 2. Re: Using a popup menu to retrieve record
            m.bodily.consulting

            Stephen,

            I understand what your saying but maybe it would help if I clarified...

            I am also using a portal on the same layout. I want to use the portal because I will have multiple records that will apply to the 1 patron whose name I will pull from the popup menu. This particular popup menu is outside the portal. I've created a script that "Go[es] to related record"...is this the right script function? It doesn't seem to work on my popup menu.

            • 3. Re: Using a popup menu to retrieve record
              hardwired-solutions

              Hello,

               

              To restate the original problem: you want a popup menu of patron's names, is that correct? If so, this can be done with a value list based on the patrons table. Please keep in mind that using a popup menu has some limitations when talking about patrons. First, you may eventually have several patrons with the same name (ie. two named John Doe). Even if you use an ID number to reference the patron, using the popup menu to show only the name will only list one of many possible John Doe's. Secondly, as your parton list grows, selecting particular patrons will become more difficult or impracticle as there will too many to scroll through.

               

              I would recommend using a list based layout and leveraging FileMaker's find and sorting features, then having a button to go to the related records of a selected patron. This should allow for greater scale and allow multiple uses (such as printing a list of patrons from the list based layout). Popup menus are generally better to use when there's a limited set of data that you might want to reference by and ID number, but display a more friendly name.

              • 4. Re: Using a popup menu to retrieve record
                Stephen Huston

                No, the GTRR is not what what you need. You need a script which does something like this pseudo-code script:

                 

                OnObjectModify for the trigger field (when you select a name in the field from the value list):

                • Commit Record
                • Set Variable $name = [field value in the popup menu selected]
                • Enter Find Mode
                • Set field [name field on whcih to search ; $name (variable) ]
                • Perform Find [no restore]

                 

                This should leave you on the same layout with the same portal but viewing the  record that you chose from the popup menu and its realted records in the portal.

                • 5. Re: Using a popup menu to retrieve record
                  m.bodily.consulting

                  Stephen,

                  I am new when it comes to writing complex scripts but I tried what you recommended and here is what I came up with: (attached file #1)

                   

                  Here is the context: The field that I want my popup menu on is for an auto created auto ID (not modifiable). The layout I'm applying this script on is for Table: Patron, it has a field named patronID. Table: Master also has a patronID field (via LookUp value). My Master table contains book info records (Author, Title, etc.) and the patronID field to indicate which patron checked out which book (if any). As seen on the screen capture above, I Set Vaiable to the value from Master::patronID.

                   

                  The problem: I get an error message saying the "action cannot be performed because field is not modifiable."

                  At first I thought the error message was because the popup menu field was a non-modifiable ID number but then I changed the field to Last_Name, which is modifiable. And I still got this error message.

                   

                  I'm beginning to think popup menus can't function like website menus where you click on a link and it takes you there (in this context my patron's checked out books would be the link).

                  I have a lot of words here so I've also attached a screen capture of everything: layout, script and inspector showing the popup field function: (attached file #2)

                   

                  Thanks for your help Stephen.

                  • 6. Re: Using a popup menu to retrieve record
                    BruceRobertson

                    Your script it not quite what Stephen suggested.

                     

                    There are three errors.

                     

                    1. Enter find mode; do NOT restore (as described by Stephen)

                     

                    2. Your set field statement is not complete. You specified the field; but not the value. It should read:

                    Set field [ Patrons::patronID; $patronID]

                     

                    3. You are using the wrong Find command. This is a little confusing, since they have similar names. But Find/Replace is not the right command.

                    You want the "Perform Find" command, which can be found in the "Found Sets" group.

                    • 7. Re: Using a popup menu to retrieve record
                      m.bodily.consulting

                      Thanks for the direction Bruce,

                      I think I got the script as Stephen had described:

                      ObjectModify_Script2.JPG

                      (see attachment)

                      However, I'm still getting an error message ("...field is not modifiable..."). This message must be because of the field type/functionality not the script itself....?

                      • 8. Re: Using a popup menu to retrieve record
                        m.bodily.consulting

                        Having the Patron field as a popup menu is only half of what I wanted. I am fairly certain on how to create a popup menu but I was more unsure about the second part of what I was looking for which is to us the popup showing Patron names to bring up related records in a portal on the same layout. I think creating a portal to do what I want is my main issue.

                        Currently my popup menu is set up like this:

                        • Display data from Patrons::patronID
                        • Values from field (Patrons::Full_Name)

                        patronID is an auto created serial number and is not modifiable.

                        Full_Name is a calculated field and therefore makes it not modifiable. This also might be the reason I keep getting an error message as stated in previous posts..?

                         

                        I also considered the point you brought up about the patron list growing to a number that makes a popup menu more annoying than efficient. I actually made another layout in case my client had this same concern. My other layout is actually a form view of my patrons (containing contact info. fields and items they checked out). On this layout I've created buttons in the heading that "Show All Patrons" which switches to table view. This view still shows contact info but not items checked out (because it is in a portal). So I have another button in the heading to "Return to Single Patron" which will go to form view for the active record. In which my client can see further details into what items this person has checked out.

                        But I have problems with this/these layouts as well: I can't get my portal to display records that the selected patron has checked out. In other words, my portal won't display records with the patronID field matching the active patron record on the Patron table.

                        • 9. Re: Using a popup menu to retrieve record
                          BruceRobertson

                          What you're talking about has nothing to do with scripting.

                           

                          Can you post your file or a simplified example? You can make a clone of your file and put some sample data in it if you don't want real data to be shared.

                          • 10. Re: Using a popup menu to retrieve record
                            digital-carpentry

                            OK I think I understand what you are looking for, and it's really a simple answer, but there are some limitations (as listed above) if you get too many patrons, or especially if you get patrons with identical names.

                             

                            The Popup menu should be on a separate field let's say "SelectedPatron"  and should be based on the PatronID but displaying the Full_Name.

                            Then set up a relationship based on Selected Patron matching Patron ID

                            Your Portal just needs to display the records based on this Patron ID matching the Patron ID in the table you want to display records from.

                             

                            Then you can select the Patron and display the Patron's records.

                            • 11. Re: Using a popup menu to retrieve record
                              m.bodily.consulting

                              Bruce,

                              I made a clone file and imported a few book records and made 2 faux patron records. I should warn you before you start looking at this file that this database has been developed by 2 other developers...and me (a wanna-be developer). There are a lot of layouts and scripts here but I tried to clean it up for you, so my concern is for the Circulation2_portal layout and the script I'm using for the popup menu is in the MB folder named Objectmodify_patron.

                               

                              Additional info: Other related layouts are (in the MB folder)

                              • Master_MBCopy (table view of all book records)
                              • Patrons3 (form & table view of patron records w/ portal for related records)

                               

                              Using the clone file I've attached let me restate what I'm trying to do here. Notice in the Master_MBCopy layout I assigned the first book ("After Damien...") to John Doe (patronID field). In the Circulation2_portal layout I want the Patron field (pop-up menu) to allow me to select John Doe and by doing this I want the "On Loan" portal to display the book "After Damien..."

                               

                              I appreciate your willingness to look at my file  to help me out.

                              • 12. Re: Using a popup menu to retrieve record
                                BruceRobertson

                                Well, it still isn't clear what you're trying to do.

                                 

                                You have attached a script trigger and a popup to change the primary key of the patron record.

                                 

                                You really don't want to do that.

                                 

                                You have also sized the fields too large to fit in the portal.

                                 

                                I've added a global selector field that will use the script trigger to find the selected record.

                                 

                                You were also entering full names rather than IDs in the PatronID field so there wasn't a way to actually link to the patron record.

                                • 13. Re: Using a popup menu to retrieve record
                                  digital-carpentry

                                  OK I looked at your solution, and there are a few things that don't make sense

                                   

                                  The PatronID field in the Master table are all blank, so they do no good for a relationship connection.  What should this field be storing?

                                   

                                  If that field held the Patron ID to match the one you were selecting in your Circulation2 layout, then the solution I gave earlier would work easily (I have attached a working example from your file that just needs the data  filled in for that field)

                                  • 14. Re: Using a popup menu to retrieve record
                                    m.bodily.consulting

                                    Thank you so much for your help Bruce!

                                    It took me a while to while to find all your changes but I applied them to my database and it works! Granted I still don't fully understand why the relationships, field additions, etc made the popup menu work. But I;ve actually learned quite a bit by your modifications.

                                     

                                    I appreciate it.