2 Replies Latest reply on Jun 9, 2014 12:14 PM by nihmbrisby

    Create new records via one line portal

    nihmbrisby

      Title

      Create new records via one line portal

      Post

           Creating new records in a child table from a parent record is, in my opinion, most easily done via a portal.  Is there a way to create a one line portal that only shows the a blank line (in which to create the new record)?  

           I tried creating a new table occurrence of the child table.  Primary key = foreign key AND Field A = Field B where fields A and B never match.  I created a one line portal and was able to create new records in the child table.  However the foreign key was not populated with the parent table's primary key.  

           Any ideas?  Thanks!

           Edit: No wait- it does work (I was looking at the wrong key).  So is this a safe method to use?

           Edit: It works but the match field on the parent side needs to change after each new record.  So I have a script trigger on the pop when it exits to change the match field using get uuid (I changed it to simply add one to the match field which is set to 1 on the parent record's creation).  Still- this one script trigger seems simpler (and better performing?) than the alternative copy key- go to layout- new record routine.  Though I'm still worried that there's something 'not quite right' about doing it this way.

           I should add it's a one line portal, but it's transparent and takes up the whole pop up menu.  So to the user, it just seems like they are creating a record on the child table. 

           Thanks.

        • 1. Re: Create new records via one line portal
          philmodjunk

               You don't need the portal. you can take the fields out of the portal and put them directly on your layout and this still works.

               And this is a method similar to a concept that I myself am using with increasing frequency.

               Use a relationship with "allow creation..." enabled that does not match to any records.

               Use Set field [ RelatedTable::Field ; "some value here" ],  or (in your case) user data entry, to create the related record

               Then use Set field [ RelatedTable::matchField ; "" ] to clear the matching value to "break" the link to the new record.

               This avoids the following issues:

               a) no script triggers are tripped by changing layouts to create a record in the portal's table as a commonly used alternate script does

               b) tab controls, portals all stay in their current state as you haven't changed layouts. (but the portal might change if you need to commit records.)

               The downside to this method is that you have to add yet another table occurrence to your relationship graph just to support this method of adding related records.

          • 2. Re: Create new records via one line portal
            nihmbrisby

                 Thanks Phil.  That's actually much better for me as there some portal behaviors that I didn't want.