12 Replies Latest reply on Aug 20, 2013 11:10 AM by Vicky

    Attach pdf to email

    Vicky

      Title

      Attach pdf to email

      Post

           Hi,

           I am trying to attach a pdf to an email.  I will upload a screenshot of the script. It was working before but now it does not work.  I do not know why it does not work anymore since I did not change the script.  I only changed the layout order in manage layout. When I click the button to send the email, it creates the pdf on the desktop but it does not attach the pdf to the email.

            

      Screen_Shot_2013-08-19_at_1.52.57_PM.png

        • 1. Re: Attach pdf to email
          philmodjunk

               Have you checked to see what value is being calculated and stored in $SpecSheet?

               A change in layouts--if that layout references a different table occurrence than the original can definitely change what results are caculated in script steps such as that set variable step.

               I can see that it refers to "models", but then you use go to related records to go to related records from "models". That doesn't normally work as usually, you specify  a table occurrence different from that of the current layout in the "Table" parameter of the Go to Related Records step.

          • 2. Re: Attach pdf to email
            Vicky

                 How can I check to see what value is being stored?

                 We have the button on the modelLayout.  Our spec sheet is based off of the same table occurence but has its own layout.  We tried using a different table occurence but it did not work.

            • 3. Re: Attach pdf to email
              philmodjunk

                   Show Custom Dialog can be used to display the contents of the variable. You can add that step as a temporary test to see what value is being put in the variable.

                   What is the purpose of using Go to related records here?

                    

              • 4. Re: Attach pdf to email
                Vicky

                     I used the show custom dialog and it shows me

                     file:/Macintosh HD/Users/TproDesigner/Desktop/.pdf

                     I deleted Go to related records. 

                • 5. Re: Attach pdf to email
                  Vicky

                       Right now it shows me the pdf icon in the email, but when I try to open it, it just shows me a bunch of gibberish.

                  • 6. Re: Attach pdf to email
                    philmodjunk

                         file:/Macintosh HD/Users/TproDesigner/Desktop/.pdf

                         would indicate that either Model::Model Name is empty at the time that your set variable step executes or that the reference to that field is not valid at the moment the Set Variable script step executes.

                    • 7. Re: Attach pdf to email
                      Vicky

                           Ok. That explains why it wasn't making the pdf icon. Thanks!  

                           We used go to related records to first go to the layout where we want the pdf to be created(spec sheet), otherwise a pdf of the current layout where the button is (model) gets created.  When a pdf of the model layout is created, the pdf gets attached to the email.  When we try to make a spec sheet pdf by using either go to layout or go to related records, it creates the pdf but it does not attach to the email.  

                      • 8. Re: Attach pdf to email
                        philmodjunk

                             I never said not to use Go To Related Records. I simply tried to point out that the combination of layouts and this script step didn't look like it was set up correctly.

                             What layout are you one when you perform this script?

                             On what table occurrence is it based?

                             How is that table occurrence related to the table occurrence of the layout from which you want to save a PDF?

                        • 9. Re: Attach pdf to email
                          Vicky

                               Sorry, someone else wrote the script so I just figured out why they used go to related records.  I don't really understand scripts so I am really grateful you're taking time out to help me out. :)

                               I am on the ModelLayout when I perform the script. It's based off of model TO.

                               The layout where I want to save a PDF is called Spec Sheet.  It is the same model TO as ModelLayout.

                                

                                

                                

                          • 10. Re: Attach pdf to email
                            Vicky

                                 I am working on a mac. My coworker is working on a windows laptop.  We tried writing the script on her laptop and it worked but when we saved a copy of the file onto the mac, it stopped working.  Is it because the path is incorrect?

                            • 11. Re: Attach pdf to email
                              philmodjunk
                                   

                                        I am on the ModelLayout when I perform the script. It's based off of model TO.

                                   

                                        The layout where I want to save a PDF is called Spec Sheet.  It is the same model TO as ModelLayout.

                                   Then you do not need Go to Related records. When two layouts are based on the same TO, they share the same found set, sort order and current record. Your script need only change layouts as the current record won't change unless the script is accidentally tripping a script trigger that someone has set on one of the two layouts.

                                   

                                        We tried writing the script on her laptop and it worked but when we saved a copy of the file onto the mac, it stopped working.  Is it because the path is incorrect?

                                   The filepath I see computed in the script in your original post should work with either Mac or windows systems for sending out the email. The filepath to the PDF will be different on different computers or even the same computer when opened with different user accounts but for the purpose of sending the email, this should not be a problem as the script creates the PDF, saves it to the user's desktop and then sends out the email immediately.

                              • 12. Re: Attach pdf to email
                                Vicky

                                     Ok! That makes sense. Thank you for your help Phil! I'll use go to layout instead of related records. Much appreciated. 

                                     :)