4 Replies Latest reply on May 22, 2013 5:24 PM by kodiak347

    Setting a foreign key


      I have the following relationships built and correctly displaying filted portals via a global field from the customers table.

      TO Question.JPG


      1. customers_CUSTOMERSITES is displaying the sites belonging to the customer and is able to add new CUSTOMERSITES via this relationship.

      2. customers_customersites_CONTACTS 2 is displaying the contacts belonging to the cutomersites via the same global variable used to filter the 1st portal and is also able to add new contacts.


      The problem I am having is I can not get the foreign key from CUSTOMERSITES of the 'currently filtered site' to set correctly, when adding a new customer via the portal. It only seems to want to set the foreign key to the 1st siteID.


      Example: Two sites for a customer. Using the portal I am looking at site #2. Using the contacts portal I attempt to add a new contact. It adds the contact but sets the __kf_siteID to Site #1 and disapears from the portal for site #2. When I change the filter to site #1 there it is and I have to paste in the correct siteID.


      I can accomplish this via a script and a new window, but would like to use the portal.


      Any suggestions?

        • 1. Re: Setting a foreign key

          the A-B-C rel tunnel will use the first value in the A-B relationship; just an extension of what is the default value of parsing a related field? - A:  the first value of the rel


          script it. Don't need a new window, can use a go 'hidden' layout

          go bts_customersites, new record, set SiteContacts::site_id  set SiteContacts::contact_id, return


          this will be invisible ordinarily

          1 of 1 people found this helpful
          • 2. Re: Setting a foreign key

            Thank you!!


            I have been able to make this work, however it annoys me that the layout



            Here is how I did it..


            image: Inline image 1

            While the immediate problem has been solved (thanks again) the portal goes

            a little crazy as it comes back to the layout, and re-enters the portal.


            The layout has also has a script trigger that fires on entry.


            Is there another possible solution?

            • 3. Re: Setting a foreign key

              You could use a dedicated ACRR (allow creation related records) rel: g_site_id = SiteContacts::site_id and g_contact_id = SiteContacts::contact_id

              script parse the key values into the two globals : g_site_id and g_contact_id, that way it does not need to leave the layout


              Why does the the cursor need to re-enter the portal?


              Step through the script using Script Debugger and look for the blink inducing point; probably something the layout script is doing; like a refresh|flush


              The flicker can be more of an issue on windows boxes/networks; do not usually see it on Macs

              • 4. Re: Setting a foreign key

                You are so right. 

                As a part of a layout based script trigger I was clearing a global field and refreshing the window with flush cashed join results enabled. 


                As soon as it was disabled, the flicker went away.


                I did not attempt the other technique, but will once I understand it better.


                Thanks cortical!