3 Replies Latest reply on Aug 22, 2013 12:28 PM by philmodjunk

    Creating a Button That Creates a New Portal Row/Entry

    CourtneyTran

      Title

      Creating a Button That Creates a New Portal Row/Entry

      Post

           How do I write a script so that I can create a button that generates a new portal row and goes to the first field of that row for data entry on a portal table?

           I want to be able to click "Add Donation" and then a new portal row generates and my cursor is already in the first field of that row for me to begin entering the donation details.

           All help very much appreciated!

        • 1. Re: Creating a Button That Creates a New Portal Row/Entry
          philmodjunk

               If you have this relationship for your layout and portal combination:

               Donors-----<Donations

               Donors::__pkDonorID = Donations::_fkDonationID

               Then this will create the new Donation record:

               Set Variable [$ID ; value: Donors::__pkDonorID ]
               Go to Layout [Donations (Donations)]
               New Record/Request
               Set Field [Donations::_fkDontaionID ; $ID ]
               Go to Layout [Original Layout]

               But how you set up your portal will determine if the new record appears at the top or bottom of your portal. In either case, use the Name box in the Inspector's Position tab to give your portal an object name.

               Go to Object ["portalObjectNameGoesHere" ]
               Go to Portal Row [ First ] ---> or last
               Go to Field [Specify field in portal row here]

               If the new portal record will appear as the last record, you might consider not using a script or button at all. In that case you can specify "allow creation of records via this relationship" and then you can add donations just by going to the botom blank row that this option adds to your portal and start entering data.

          • 2. Re: Creating a Button That Creates a New Portal Row/Entry
            CourtneyTran

                 Thank you so much. I cannot thank you enough.

                 Also, and this is a minor point but,

                 each time I enter in a new donation on my portal, the next row automatically opens up (a new blank row).

                 I would actually much prefer that it does not do this but that it, instead, opens the new portal row only once I click on "Add a Donation".

                 Is there an option to get rid of this feature on my table? There doesn't appear to be...

            • 3. Re: Creating a Button That Creates a New Portal Row/Entry
              philmodjunk

                   You'll recall that i Mentioned the "allow creation..." option in the underlying relationship? That is the option that is adding this additional blank "add" row and is where you can add a new related record simply by entering data in a field in this row. If you do not want that, you can go to Manage | Database | Relationships and clear that option.