1 2 Previous Next 17 Replies Latest reply on May 11, 2010 3:07 PM by aammondd

    Conditional Portal Relationships

    aammondd

      Title

      Conditional Portal Relationships

      Post

      Before I go too far in testing this idea I wanted to know if there is anything that may create a hangup for this or if there is simply a better way to do it.

       

      I have a Person Table with different types of people it in. I collect several types of information about these people in a few different tables. Each of these are one to many relationships  though some types of people may not have information in each of the tables because its not relevant.

       

      What I was considering was creating a calculation keys in each record that combined the personID  and the type of record it was and possibly a third key field. Then I was going to create a global record that allowed me to select the various keys values.

      I was also going  to create a calculation record that displays the data based on the global keys selected.

       

      I was thinking of doing this by running a script trigger off the changes in the global keys to create the appropriate number of keyed calculation records based because Ill need 1 keyed calculation record for each child record from the appropriate table.

       

      Im working in FMP 10 Advanced on a Mac

       

      It would be so much easier if I could set the relationship of the portal by Calculation or Field Value but that too would present problems.

       

      has anyone done anything like this.

      I was going to have an "Edit" ,"+" and "-"

      to allow to change add or delete the related records because they couldnt change anything in  the calc table.

       

      Any thoughts are appreciated.

        • 1. Re: Conditional Portal Relationships
          comment_1

           


          aammondd wrote:

          I wanted to know ... if there is simply a better way to do it.


           

          Maybe - but you didn't tell us what "it" is...

           

           


          aammondd wrote:

          I have a Person Table with different types of people it in. I collect several types of information about these people in a few different tables. Each of these are one to many relationships 


          Shouldn't it be one-to-one?

           



          • 2. Re: Conditional Portal Relationships
            aammondd

            "The IT being I want a portal that displays conditionally select data across multiple tables in a single portal."

            I realize that I could just have a set of tabs but the types of data also can be conditional based on the type of person.

             

             

            A person can have many phone numbers for example

            but they may not have an email address 

             

            Doctors for example may have a number medical of certifications

            Patients are not likely to have any

             

            One person different types of data often in one  to many relationships.

             

             

             

            • 3. Re: Conditional Portal Relationships
              comment_1

              A portal is permanently "wired" to a specific TO, selected in portal setup ("Show related records from: [TO]"). You cannot dynamically switch the portal to show records from another TO. Same goes for the fields in the portals.

               

              Although it might be possible to construct a "helper" table with calculation fields, you will still face the problem of the number of related records: suppose one person has 4 e-mail addresses, and another has 2 medical certifications. I am not saying it's not possible, but it certainly won't be simple - and not very fast either.

               

              OTOH, in version 10 it is very easy to switch tab controls automatically based on record's type, using a triggered script.

              • 4. Re: Conditional Portal Relationships
                aammondd

                Im planning on using a helper record and creating  the helper records from a script trigger. Since any one "related" record is not likely to contain more  than a dozen records creating the "helper" records should  be pretty easy and quick

                 

                I've created dynamic portal keys before but never across records. Im more concerned about refreshing calculations at the appropriate level

                 

                Im not exactly sure the best way to create those helper records.

                 

                I think Ill need a layout for each child with related fields back to the helper table.

                Ill find the matching child record and create the keys in the related fields.  (The relationship allowing create related records should make this easy)

                 

                Logically the script should do this

                Go to Helper layout 

                Delete all records

                Go to appropriate layout

                Find related child records

                Loop through records

                 Enter data into related (helper) record field triggering the creation of the helper record

                End Loop

                Return to Original Layout.

                 

                It should be very fast if only a dozen or so child records need to be created

                 

                I can pass all the needed values from the global table used to select the portal options in the first place.

                 

                 

                 

                • 5. Re: Conditional Portal Relationships
                  comment_1

                  If I had to do this, I would keep a permanent number of records in the helper table (more than I'll ever need), and use a calculation field in the main table to "cut off" the excess records.

                  • 6. Re: Conditional Portal Relationships
                    aammondd

                    Creating the records works very well so far in testing. I just wish scripts allowed Case Navigation instead of If Else and so forth.

                     

                    What would be the best script trigger for a radio button of a global field to do this with.

                    • 7. Re: Conditional Portal Relationships
                      aammondd

                      My script for creating the helper records is not very dynamic and Id like to make it so is there a way to do the find using a dynamic field reference

                       

                      Currently I dynamically go to the layout needed but I dont know a way to go to the "table::personID" field where "table"  is based on the layout I go to.

                       

                      Because once the find is done Ill be actually creating a record in a consistent table Helper:CreateBox

                      (I just enter a value "X" into the related field box and the relationship creates the record ) 

                       

                      Logically now my script works as follows

                       

                      Capture  the layout needed

                      Go to helper record layout

                      Show all

                      Delete all

                      Do to appropriate layout

                      Perform find

                      Loop through records creating record

                      Return to main layout

                       

                      Currently I im using IF logic to determine which loop to go through and all the loops are identical except for the  field I need to use to find in.

                       

                      Im pretty sure there is an easier way to do this so I can make this kind of thing Table driven. Im just having brain lock at the moment.

                       

                      • 8. Re: Conditional Portal Relationships
                        aammondd

                        How does one copy script steps as text regular copy functions dont seem to do it.

                         

                        FM 10A on a MacBook Pro

                        • 9. Re: Conditional Portal Relationships
                          philmodjunk

                          aammondd wrote:

                          How does one copy script steps as text regular copy functions dont seem to do it.

                           

                          FM 10A on a MacBook Pro


                          Since you have advanced, you can generate a database design report and copy the script from the report to the clipboard. Then you can paste your script into a forum message box.


                          • 10. Re: Conditional Portal Relationships
                            comment_1

                             


                            aammondd wrote:

                            How does one copy script steps as text


                            Select the script and choose Print… >  Preview. Copy the text from the preview window.

                             


                            • 11. Re: Conditional Portal Relationships
                              aammondd

                              Thanks

                               

                              Im quite liking the helper record concept

                               

                              The more I look at it FM10A doesnt have the ability to  Set Field based on a dynamic field name.

                              Would there be another way to accomplish this same thing.

                              • 12. Re: Conditional Portal Relationships
                                philmodjunk

                                Check out the script step Set Field by Name in the filemaker help system. Note that you have to specify the table occurrence as well as the field's name.

                                • 13. Re: Conditional Portal Relationships
                                  aammondd

                                  So I could store the Record::Field in a global table then populate the Set Field by Name specify field to the Global Field and that should work right?

                                   

                                   

                                  • 14. Re: Conditional Portal Relationships
                                    philmodjunk

                                    Almost. You would store the TableOccurrenceName::FieldName. Note that this does not store the ID of any specific record within that specified table. Generally, you should avoid this unless it is truly necessary. Set Field by Name can lock you into a situation where changing a field's name in Manage | Database | FIelds causes your script to silently fail.

                                     

                                    (Silent failure means the script is not interrupted with an error dialog so you don't know anything went wrong unless you checked for the error or you notice that the script didn't produce the desired result.)

                                    1 2 Previous Next