7 Replies Latest reply on Mar 8, 2012 1:35 PM by 4justme2

    Portal used to Select and/or Add Records - not working



      Portal used to Select and/or Add Records - not working


      I have a portal(on the PARENT table from the PARENT_2_CHILD relationship below) used to Select records from a value list which is working fine.  I'm trying to write a script that will allow me to create new CHILD records from within the portal (first checking to make sure the portal row is empty). I am only successful to the point where the new record is created.  I have a button on the portal row with a dropdown value list.  The enduser can pick a value from the list and the other fields auto populate.

      However, when the enduser click on the portal row to add a record nothing visably appears to happen (although, behind the scenes the new record is generated). 








      My relationships are set up where I can create records on both sides of the join table, PARENT_2_CHILD

      I have a value list based on the CHILD table which provides values to the drop down list on the portal.  All of this is currently working. I tried my hand at writing a script to add new records to the portal the only thing I seem to be able to accomplish is to generate the new primary key in the CHILD table and be returned to the portal on the PARENT table.

      Here's my sad attempt at the script to add a new child from within the portal on the PARENT layout:

      Set Variable [$ID_PAR.pk; Value; GET (ScriptParameter)]

      Go to Layout ["CONTACTS" (Contacts)]

      New Record Request

      Set Field [PARTICIPANT_2_CONTACTS::PAR_ID.pk::$PAR_ID.pk]

      Go to Layout [original layout]


      Any suggestions on what I might revise to get new records in my portal?


        • 1. Re: Portal used to Select and/or Add Records - not working

          You appear to have these relationships:


          To add a new child, you need to add two new records--one in the child table and in the Parent_2_Child join table and the necessary primary key from the new child record must be entered into the new join table record along with the primary key from the Parent record in order to link the new Child record to the current Parent record.

          I'd use:

          Freeze window
          Set Variable [$ID_Par.pk; value: PARENT::PARENT_ID.pk]
          Go to Layout [Contacts]
          New Record/Request
          Set variable [$ID_Contact ;value: Contacts::Con_ID.pk]
          Go to Layout [Participant_2_contacts]
          New Record/Request
          Set Field [Participant_2_contacts::PAR_ID.fk ; $ID_Par.pk]
          Set Field [Participant_2_contacts::CON_ID.fk ; $ID_Contact]
          Go To Layout [original layout]

          Though your original script should work if you enabled "allow creation of records via this relationship" for Participant_2_contacts in the contacts to Participant_2_contacts relationship.

          • 2. Re: Portal used to Select and/or Add Records - not working

            I made those corrections to my script.  Also I checked to make sure I enabled "allow creation of records via the relationship for Participant_2_Contacts in the Participant_2_Contact relationship. I've still got something going now. Now I'm creating the new records in both the Contacts and Participant2_Contacts tables as desired but am still not working right on the portal side.

            It occurs to me that I neglected to mention something--I don't know if it's causing my problem. Although I have the portal on the Participant layout... it is layered under a Control named "CHILD".  

            I try adding one last line to the script, after Go to Layout [original layout] which reads: Go to Object[Object Name:"Child"] but it doesn't seem to be having any impact... when I click the add button I have brought back to the first control on the layout, not the second one labeled "Child".

            Any ideas?



            • 3. Re: Portal used to Select and/or Add Records - not working

              Although I have the portal on the Participant layout... it is layered under a Control named "CHILD". 

              I don't know what you mean by "layered under a control"

              The "allow creation" is an alternative to modifying your script to match mine. You do not need it enabled if you use my script. You DO need it with your original script.

              Make sure that $ID_Par.pk is getting a value. I use a button outside the portal for this purpose. It adds a blank record in the portal linked to a new blank record in the third table (contacts in your case).

              You may want compare what you have set up to the script in this demo file: http://www.4shared.com/file/dZ0bjclw/ManyToManywDemoWExtras.html

              • 4. Re: Portal used to Select and/or Add Records - not working

                 Ok, I'll do that.  Actually, I tried looking at the earlier.  I tried to isolate just the funtions that correspond to the Basic Setup Layout (excluding elements used for the diminishing value and checkbox utilities. What confused me was the script on the add button on the basic Setup page references a the EvDmVlContacts layout and variable. 

                In isolating just want I would need to run the Basic Setup I thought I'd only need to Contacts, EVents and Contacts_Events table occurances. I found it confusing that the script referenced a TO that was related to diminishing values.  So after some struggle I gave up and thought I'd apprach this differently.

                In regard to the scenario above... I find that although my new records are being generated as a result of the script, the serial numbers are not accurate... I have all my serial numbers formatted with five zeros and a number. And all of my primary keys prohibit modification.  The ones generated as a result of the add script lack the leading zeros.  Do youhave any guess why that would happen?

                • 5. Re: Portal used to Select and/or Add Records - not working

                   Ok, well I was working on a layout page that had a three tier tab control and I had my portal placed on the second tab.  Just for kicks I got rid of the first tab and now I am creating records through the portal... but my join table is still collecting serial numbers that drop the leading zero from both foreign keys.  Have you ever heard of that happening?

                  Where the serial number should be 000030 what I see is 30, where the serial number should be 000073 I see 73.  Could it be the variable?  Is there a way to format the variable?


                  Ahhh, I set my serial numbers to text and now I don't seem to be having that problem.  Should serial numbers be in text format?

                  • 6. Re: Portal used to Select and/or Add Records - not working

                    Check my response to your other post with regards to the demo file. The script just need a layout based on the correct table, it has nothing to do with the diwindling value list example other than that the layout referenced happens to come from that set of layouts.

                    Personnally, I wouldn't use leading zeroes in my serial numbers in the first place. I'd use a separate field that formats them with leading zeroes if I need leading zeroes to meet the display requirements for a layout or report. I suspect that you have leading zeroes specified for a serial number field of type number. If so, you can change the field types to text and this problem should disappear. When an expression refers to a number field, it's numeric value is what will be returned and that's what gives you 30 instead 000030. You can also try using the getastext function when setting the variables or this expression can preserve your leading zeroes:

                    Right ( "00000" & SerialNumberField ; 6 )

                    this last expression is what I use in a calculation field to format serial numbers with leading zeroes.

                    • 7. Re: Portal used to Select and/or Add Records - not working

                      Oh, I see what you mean.  Thanks for all of your time and patience Phil.