9 Replies Latest reply on Jun 21, 2016 1:35 PM by dtcgnet

    Printing selected record from a portal list.

    ajayz

      Hi,


      I have a layout that lists all rent payments for a property within this portal.

       

      Screen Shot 2016-06-13 at 2.26.08 PM.png

       

      I've added an EMAIL button next to each rent payment within the portal.  This  will all the user to email the receipt to the tenant.

       

      The script attached to the button is basically looking at the related record.

       

      Screen Shot 2016-06-13 at 2.29.08 PM.png

       

      Screen Shot 2016-06-13 at 2.28.52 PM.png

      I must be doing something wrong as it only seem to only generate the receipt for the first rent payment within the portal, and not the record selected.

       

       

        • 1. Re: Printing selected record from a portal list.
          user19752

          "Save Recrds as PDF" step need "Records being browsed" option (mean "all found set"), not "Current record".

          • 2. Re: Printing selected record from a portal list.
            ajayz

            Hi,

             

            I only want to generate a receipt for the selected rent paid (i.e. one line within the portal) , not for all rents paid as your suggestion did.

             

            By changing as you suggested generated a pdf showing all rents paid that year.  Every rent record within the portal.

             

            Thanks for taking the time to answer.

            • 3. Re: Printing selected record from a portal list.
              Mike_Mitchell

              The Commit step is partially what's sabotaging you. It takes the focus out of the portal, so you lose the current row.

               

              But the larger problem is that GTRR gives you the related set, not the chosen related record. You'll need to capture the key for the desired record and perform a Find for this to work.

               

              HTH

               

              Mike

               

              P. S. I wouldn't use Halt Script here. It will leave you on the related layout, which will likely be confusing for the user. Navigate back to the original context if you don't find the record for some reason, then use Exit Script instead. (And a dialog telling the user that something is wrong wouldn't hurt.)   

              • 4. Re: Printing selected record from a portal list.
                user19752

                Hmm, I misread since there are "from to" field so I thought there are many related records from a portal row.

                • 5. Re: Printing selected record from a portal list.
                  dtcgnet

                  Remove lines 3-7. Replace with:

                   

                  Set Variable: $IDtoFind ( Lease::PrimaryKeyField )

                  Go to layout "Rent Receipt"

                  Enter Find Mode

                  Set field Rents::ForeignKeyFieldForLEASE = $IDtoFind

                  Perform Find

                   

                  Though error checking is a good idea, when you're clicking on a specific record, you know it exists, so there's no real reason to check to see if it exists. You wouldn't be able to click on it if it didn't exist.

                   

                  Also, you don't need the Commit Records in the LEASE table because you're changing to a RENTS table, and the commit is therefore not necessary.

                  • 6. Re: Printing selected record from a portal list.
                    Mike_Mitchell

                    Unless you hide the button in the portal, or the portal doesn't allow new record entry, there will still be a button on the empty row ...

                    • 7. Re: Printing selected record from a portal list.
                      dtcgnet

                      Good point if he's allowing record creation through the relationship!

                      • 8. Re: Printing selected record from a portal list.
                        tackermax

                        This was really helpful. However, there are a couple things that I'm not experienced enough to understand.  I'm trying to tweak it to work for my solution.

                         

                        Here is exactly what I want to do:

                        I want to save a layout as PDF, and attach it to an email with merge fields in the message body.  These tables are related by an ID field, one to many.  table1 has contact information based on the ID.  table2 has portal rows with multiple values.  i.e.  Fred and Mary Pullman have listed 2 guardians for their children.  Fred and Mary are on the main table, while the 2 guardians names and addresses are in a portal on another layout.

                         

                        Example:

                        layout1

                        I, <<table1::calc_fullname>>,  (wording about legal matters concerning) <<table1::calc_first_names>>.

                        I name you <<table2::portalrow1_name>>, as blah blah blah.

                         

                        layout2

                        Dear <<table2::portalrow1_name>>,

                        Attached you will find a legally binding letter signed by your friend <<table1::calc_fullname>>.

                         

                         

                        Then, I need to repeat for each row in the portal.

                         

                        layout3

                        I, <<table1::calc_fullname>>,  (wording about legal matters concerning) <<table1::calc_first_names>>.

                        I name you <<table2::portalrow2_name>>, as blah blah blah.

                         

                        layout4

                        Dear <<table2::portalrow2_name>>,

                        Attached you will find a legally binding letter signed by your friend <<table1::calc_fullname>>.

                         

                        So far, what I have come up with from this thread is as follows:

                         

                        set error capture [on]

                        freeze window

                        set variable [$IDtoFIND: Value: table1::agreementID]

                        Go to Layout [“layout1” (table1)]

                        Enter Find Mode [Restore; Pause]

                        Set Field [table2::ID ; $IDtoFIND ]

                        Perform Find [Restore]

                        Print Setup [Restore]

                        Set Variable [ $PATH ; Value: Get (TemporaryPath) & “layout1.pdf” ]

                        Save Records as PDF [Restore ; No dialog ; “$PATH” ; Current record ]

                        Send Mail [ Send via E-mail Client ; To: table2::email ; Subject: “You have been named…”;

                        Message: “Wish I could put <<merge fields>> in here, that would be great” ]

                         

                        It creates the email, but does not attach the file.  I have specified the file as $PATH/temp_guard_nomination1.pdf.

                        Once I can do this for one portal row, I need to loop through and create another email to the next person listed in the portal.

                         

                         

                        I am on FM 14.0.5.

                        1 of 1 people found this helpful
                        • 9. Re: Printing selected record from a portal list.
                          dtcgnet

                          In your Message, don't use merge fields. Use the real fields. Example:

                           

                          Message: "Wish I could put " & Table::Field & " in here. That would be great."

                           

                          Note that I put a space after put, and one before in.

                           

                          As for the path, create a new variable: $PathToFile = $Path & "/temp_guard_nomination1.pdf"

                           

                          Give that a shot.

                          1 of 1 people found this helpful