2 Replies Latest reply on Dec 9, 2011 8:42 AM by philmodjunk

    Make your spouse linkable to their profile:  Part 2

    FM_Rookie

      Title

      Make your spouse linkable to their profile:  Part 2

      Post

      This is related to a previous question: Make your spouse linkable to their profile

      It has been suggested that I start a new thread, so here is the question (there have been a few responses to my questiion on the old thread I will post here.

      posted December 5, 2011 by FM_Rookie

      How do you also automatically have the Spouse you just connected to the Contact also be connected with the Contact (as their Spouse) when you are viewing the Spouses profile as Contact? (I'm sorry if that's confusing)  I don't want to have to go to the Spouse & do the same for them.

      Thanks


      posted December 5, 2011 by Mark Gores

      If you have the contactID for each contact, then added a spouseID field to your contact table, you could relate a second TO of contacts called "Spouse"

      Contacts::contactID = Spouses::SpouseID

      Then set up a script so when you click the button to put Zoie"s ID in John's spouseID field, it also puts John's ID in Zoie's spouseID field.

      Or you could set something like this up to trigger "On Modify" for the spouse ID field.

      Freeze Window

      Set Variable $contact = contacts::contactID

      Set Variable $spouse = contacts::spouseID

      perform find (contacts::contactID = $spouse)

      Set Field spouseID; $contact

      perform find (contacts::contactID = $contactID)

      Show All Records

      Refresh window

      posted December 5, 2011 by PhilModJunk

      Note: another option that allows you to link more than just two individuals to the same contact record is to use a join table--which then permits linking any number of people to the same contact record (all memembers of one family and living at the same residence, all employees of the same company....)

      Current Response/Question to PhilModJunk

      This was my orignal idea, but I couldn't figure out how to make the people I linked to have the original person in their portal when it was accessed.  In other words, if I associated Person1 with Person2 in LayoutA:PortalA, how do I set it up so that when I look at Person2 in LayoutA, Person2 appears in PortalA?  Because the portal is set up to show Person2's ID as the spouse, not Person1's.  (if this is confusing, I can upload a screenshot)

      Thanks! And thanks others for your insight.  I just need to decide which approach will work best for us after I understand them all.

        • 1. Re: Make your spouse linkable to their profile:  Part 2
          mgores

          I think this would work with the join table method as well if you set the IDs for the two people you want to link as variables

          $person1 and $person2

          The have your script create 2 new records in the join table with one having join::contact = $person1 and join::related = $person2

          and the second record having join::contact = $person2 and join::related = $person1

          So you would have 

          Join::contact       Join::related

                1                    2

                2                    1

           

          Then your TableA layout for each person will show the related person(s) in the portal.

          • 2. Re: Make your spouse linkable to their profile:  Part 2
            philmodjunk

            This is called a many to many relationship.

            Personnel-----<Contact_Person>-----Contacts

            Personnel::__pk_PersonnelID = Contact_Person::_fk_PersonnelID
            Contacts::__pk_ContactID = Contact_Person::_fk_ContactID

            You use a portal to Contact_Person on a Contact layout to list all personnel (all in the family all in a company...) with that same contact info. In similar manner, a portal to Contact_Person on the Personnel layout can list all that person's contact records. (They might have a contact record for Home and another for work. A child with divorced parents might have a different contact record for each person...)

            I have a demo file that links events to contacts in a many to many relationship with lots of added comments to explain how it is set up. It then goes on to illustrate some additional, more sophisticated ways for managing many to many relationships--including a diminishing value list and a portal that functions as a list of check boxes.: http://www.4shared.com/file/dZ0bjclw/ManyToManywDemoWExtras.html