1 2 Previous Next 16 Replies Latest reply on May 31, 2013 10:28 AM by ascii7x

    The ability to allow 1 checkmark in all records in portal

    ascii7x

      Hello, I have been busting my hump on how to script or find afunction that would allow me to let users only select one checkmark in the records in a portal.

      In other words, we have a portal for our main clients, these clients have emergency contacts. Each emergency contact created creates a new record in the "phoneNumber" table. In the phonenumber table, there is a unique phonenumberID. In that same table, those numbers are associated with a contactID for theclient that provided these phone numbers. In each record, there is a check-box that our employees click on to mark it as a main number. In that same portal, any number(record) that is marked as "Main Number", it gets sorted to the top of the portal. This main number that gets selected gets placed in a field used for printing cards. The problem is that if this number is unchecked from 'main number' and a new number is checked as "main number", it will not display it. I would like to be able to only allow one one number in each portal to be "main number". If a main number is selected and there is one already that have been selected as "main number" I would like the user to get an error message letting them know only one is possible. The FM feature of custom diaglog does not allow me to create a script to run when a button is clicked so I created a separate window(layout) with my buttons and a script on each to allow it to change a variable in the other layout to allow the movement throught the logic of the code which has a loop to count records in the portal to keep track of record rows done.

       

      I tried different code methods butdoes not work correctly. Before writing this request, I thought what if, there was a way to collect the phoneNUmberIDs for the specific ContactID and then go through each of the records in phonenumber table or portal and uncheck the "main number" on all records that were previously checked and the new number that was checked to get the checkmark.

       

      Please help with this confusion.

       

      thanx.

        • 1. Re: The ability to allow 1 checkmark in all records in portal
          sporobolus

          on 2013-05-29 18:50 ascii7x wrote

           

          Hello, I have been busting my hump on how to script or find afunction that would allow me to let users only select one checkmark in the records in a portal.

          In other words, we have a portal for our main clients, these clients have emergency contacts.  Each emergency contact created creates a new record in the "phoneNumber" table.  In the phonenumber table, there is a unique phonenumberID.  In that same table, those numbers are associated with a contactID for theclient that provided these phone numbers.  In each record, there is a check-box that our employees click on to mark it as a main number.  In that same portal, any number(record) that is marked as "Main Number", it gets sorted to the top of the portal.  This main number that gets selected gets placed in a field used for printing cards.  The problem is that if this number is unchecked from 'main number' and a new number is checked as "main number", it will not display it.  I would like to be able to only allow one one number in each portal to be "main number".  If a main number is selected and there is one already that have been selected as "main number" I would like the u

          ser to g

          e

          t an error message letting them know only one is possible.  The FM feature of custom diaglog does not allow me to create a script to run when a button is clicked so I created a separate window(layout) with my buttons and a script on each to allow it to change a variable in the other layout to allow the movement throught the logic of the code which has a loop to count records in the portal to keep track of record rows done.

           

          i don't know enough details of your workflow to know if this will meet your

          needs exactly, but my first thought was the main-contact info belongs in the

          parent record not in the child record; so here's a possible design

           

          first the structure; i assume you already have:

           

             client -< phonenumber
          

           

          (i'm assuming phonenumber record is same as a contact record, but you may have

          another layer here)

           

          make these changes:

           

          1. add a field to client, "main_contact_phonenumberID"

           

          2. make another TO of phonenumber "main_contact_phonenumber"; create this relation:

           

             client >- main_contact_phonenumber
          

           

          for the interface, instead of a checkbox, use a button in the portal to

          designate that number as the main contact number; when clicked, the button will

          simply set main_contact_phonenumberID to the id of the phonenumber record

          clicked; this settles the question of avoiding multiple main contacts, since

          clicking the button replaces the old value

           

          now it's up to you how to show this on the interface; for example conditional

          formatting could compare the id of the phonenumber record in the portal to

          main_contact_phonenumberID in the client record

          • 2. Re: The ability to allow 1 checkmark in all records in portal
            ascii7x

            Thank you for your response.

            Let me explain more:

             

            Our "Contacts" database houses all common data from the following tables/layouts:

            Patients

            Leads

            Consumers

            Doctors

            Nurses

            Employees

             

            All phone numbers are house in a table called "Phone Numbers".

            The reason why we have a separate table is because we need to keep a history of their phone numbers.

            Sometimes, they move and get a new number.  Then, they come back and get the previous number back.

            In case we need to reach them when they get back but forgot to provide us their previous number, we will have it on record.

            For instance, we had a patient move out-of-state, we changed their phone number.  One year later, they move back and tell us to call them at their previous phone number.  Guess what, we did not have it.  It too the individual to call us back two months because we did not have the previous number before they moved.

            That's the reason why we keep phone numbers separate, same with e-mail.

             

            In our "contacts' database we have a field called "__kp_ContactID".

            In our "PhoneNUmbers" table we have a corresponding field called "_kf_ContactID" as well as a unique ID field called "__kp_PhoneNumberID".

            The relationship is via "__kp_ContactID" --> "kf_ContactID".

             

            The portal is located in the "Contacts" layout.

            It holds all the current contact's phone number, phonetype,contactType,phoneNumber, as well 3 checkboxes(they are separate) to mark it as a main number, an EmC1 and EmC2 (emergency contact #1 and #2).  That is what is displayed in the portal rows.  Checkboxes first.

             

            In the portal, the sort is set to display the "main number" first in the portal in ascending order.

            So if we have two numbers in two different rows as main number, those two are on top and the others below.

             

            The problem with the script when it counts and unchecks one of the extra checkboxes for "main number", it pushes that record to the bottom.

            Now, when I do a go to do a "next record row" it will read the record that got unchecked again and mess up the count.

             

            That's why I was wondering if there is a way to capture all the "phonenumberIDs" for the specified "contactID" and then call each "phoneNUmberID" and uncheck it via script one by one, without worrying about the portal rearranging the records as one gets unchecked.

            • 3. Re: The ability to allow 1 checkmark in all records in portal
              ascii7x

              Here is the pic for the phoneNUmber portal:

              phoneNUmberPortal.JPG

               

              This is the code for the script if a checkmark is clicked:

              script1.JPG

               

              end of script page:

               

              script2.JPG

               

              hope this helps

              • 4. Re: The ability to allow 1 checkmark in all records in portal
                BruceRobertson

                I think Steve understood enough about your approach; which is more complicated than necessary. Drop all those scripts; re-read Steve's reply. You do not need to mark/unmark batches of records and you do not need mark fields in those records.

                • 5. Re: The ability to allow 1 checkmark in all records in portal
                  ascii7x

                  Thank you Bruce.

                  Wow!  Really?

                  The problem also, is that this portal was created by another person and that many of the records have multiple "main numbers".  I was going to have each rep go through their "contacts" and check the correct "main number" and through the process it would uncheck the other "main numbers".  Then in the future, if someon wants to check a different "main number" it would automatically uncheck the other "main number".  I guess if I place a button, I can create a script that in the background that a boolean would hold the value of "1" if it's the "main number" and then using conditional formatiing highlight the portal row that is "main number" because of the boolean value.

                   

                  I was really hoping to use the check box method, because management loves check boxes and radio buttons.  They are not much into buttons, they feel the employees would get confused.

                   

                  Is it possible to make the checkbox feature work?

                   

                  I was hoping I can capture the "__kp_phoneNUmberID" for each contact and then manually select each one and uncheck it via script.

                  • 6. Re: The ability to allow 1 checkmark in all records in portal
                    ascii7x

                    Is there a way I can move a variable from one layout to another?

                    Also, is there a way to uncheck a checkbox via script?

                    • 7. Re: The ability to allow 1 checkmark in all records in portal
                      BruceHerbach

                      If you use a Global variable $$ it is available to all other scripts/layouts in the file.  Or you can pass a variable as a script parameter.

                       

                      Use Set field with the value "".

                      • 8. Re: The ability to allow 1 checkmark in all records in portal
                        ascii7x

                        How do you correctly pass a variable?

                        I have searched on the proper syntax online but was not able to find syntax.

                        I decided to use a button with conditional formatting to change the button properties. In the main script i do create two global variables because the button calls a different layout with two buttons. One cancels the other is supposed to place the data in the variables to the contact table

                        • 9. Re: The ability to allow 1 checkmark in all records in portal
                          BruceRobertson

                          It will be a lot easier to help you if you post your file; or a clone; or a simplified, similar, example file.

                          • 10. Re: The ability to allow 1 checkmark in all records in portal
                            sporobolus

                            on 2013-05-30 16:06 ascii7x wrote

                            How do you correctly pass a variable?

                            I have searched on the proper syntax online but was not able to find syntax.

                             

                            there is no syntax per se; if you set a global variable, it is available in all

                            scripts in a file; passing parameters is another matter; there isn't a syntax

                            for this so much as slots you can fill in while you point and click your way

                            through scripting; then you need to know to get(scriptparameter)

                            • 11. Re: The ability to allow 1 checkmark in all records in portal
                              BruceRobertson

                              "Is it possible to make the checkbox feature work?"

                               

                              Yes. Steve described how. It's just not the way you imagine it.

                               

                              If there is only one main number for a contact then this is a property of the contact record, NOT a property of the phone number record.

                               

                              You're making this way too hard.

                               

                              What version of FileMaker are you using?

                              • 12. Re: The ability to allow 1 checkmark in all records in portal
                                ascii7x

                                here is the script via picture:

                                Capture.JPG

                                 

                                the button that calls it is in the portal.

                                conditional formatting hides the 'x' in the button n makes the button a different color.

                                • 13. Re: The ability to allow 1 checkmark in all records in portal
                                  BruceRobertson

                                  Example files demonstrating Steve's technique. Quick and dirty example.

                                   

                                  It retains the APPEARANCE of phone-record based checkboxes but they are actually contact-based fields. Selection of main/emergency contacts controlled by scripts.

                                   

                                  Files in fp7 and fmp12 format attached.

                                  • 14. Re: The ability to allow 1 checkmark in all records in portal
                                    ascii7x

                                    Bruce, thank you for the files, especially the phonenumber one.  It works exactly how I needed it to.

                                    I am so burnt out of writing and rewriting script that I know am in a state of dumbness.

                                    I found this out when I tried to read your code and could not understand it.

                                    My aplogies, I do need a day off from this.

                                    Can you please explain what the code is doing so I can absorb it.

                                    Confusesd about "close window" and "freeze window", this is something I am not familiar with.

                                    I am leaving early work today because I am burnt out spending the whole, each day over 10 hours playing around with it.

                                    Thank you.

                                    josh

                                    1 2 Previous Next