AnsweredAssumed Answered

Extract file from container and send via Email Issue

Question asked by user2148443 on Dec 17, 2018
Latest reply on Dec 17, 2018 by philmodjunk

I have an issue. I have a Global Field that contains a PDF of clients Terms and Conditions. i am trying to attach to an email. However, i am also generating a PDF from a layout for the Quotation.

 

Now i don't have an issue generating the quotation and attaching that to the layout. it is attaching the Terms & Conditions, where i am having problems. Although the email is attaching the two files. It is actually sending to copies of the quotation, but renaming one as the Terms and Conditions PDF.

 

I have tried

     1) to attach the file via Export Filed contents, but comes up with an issue unable to create a directory, and opens a blank email, without the client details.

     2) via setting as a local Variable.

     3) Setting as a Global Variable.

 

There is another step where i record the emailing of the files for auditing and proof purposes as evidence as well, which is not working either at present but the email is the biggest concern.

 

# Prepare the record

Freeze Window

Allow User Abort [ Off ]

#

# Setting Variables to Save to Related Documents Table

#

Set Variable [ $PATH ; Value: "" ]

Set Variable [ $TC_PDF ; Value: "" ]

Set Variable [ $CUSTOMERID ; Value: TO_002____Customers::CUSTOMER ID MATCH FIELD ]

Set Variable [ $$TC_PDF ; Value: TO_001____PREFERENCES::Terms_Condtions_PDF_Global ]

Set Variable [ $Date ; Value: Get(CurrentDate) ]

Go to Related Record [ Show only related records ; From table: “TO_002____Customers” ; Using layout: “LO_015_QOUTE_LAYOUT” (TO_002____Customers) ; New window ]

Set Error Capture [ Off ]

#

If [ Get ( LastError ) ≠ 0 ]

  Halt Script

End If

#

If [ IsEmpty  (TO_002____Customers::Office Email) ]

  Show Custom Dialog [ "System" ; "No Billing Contact is selected or Email is empty" ]

  Close Window [ Current Window ]

  Exit Script [ Text Result:    ]

End If

#

Show All Records

Omit Record

Show Omitted Only

#

Enter Preview Mode [ Pause: Off ]

#

# Prepare the pdf

Set Variable [ $PATH ; Value: Get ( TemporaryPath ) & TO_002____Customers::SiteAddressShort &"_" &Substitute ( Get ( CurrentDate ) ; "/" ; "-" )&  ".pdf" ]

Save Records as PDF [ Restore ; With dialog: Off ; “$PATH” ; Records being browsed ; Create directories: Off ]

#

# Set T&C PDF

// Set Variable [ $TCPDF ; Value: TO_001____PREFERENCES::Terms_Condtions_PDF_Global ]

Export Field Contents [ TO_001____PREFERENCES::Terms_Condtions_PDF_Global ; “$TERMS” ; Create directories: Off ]

#

// # Send Email

// Send Mail [ Send via E-mail Client ; With dialog: On ; To: TO_002____Customers::Office Email ; Subject: "Quotation from Evergreen Blades" ; Message: TO_001____PREFERENCES::Quotation Email Body ; “$PATH” ]

# Send Email

Send Mail [ Send via E-mail Client ; With dialog: On ; To: TO_002____Customers::Office Email ; Subject: "Quotation from Evergreen Blades" ; Message: TO_001____PREFERENCES::Quotation Email Body ; “$TERMS” ]

#

#

If [ Get(LastError) ]

  Show Custom Dialog [ "System" ; "Failed to send the Email, please check your connection" ]

  Close Window [ Current Window ]

  Exit Script [ Text Result:    ]

End If

#

#

# Exit Script

Close Window [ Current Window ]

#

// # Save to Related Documents Table

// #

// New Window [ Style: Card ; Name: "Saving Qoutation" ; Using layout: “LO_017_PROPERTY_RELATED_DOCUMENTS” (TO_015____PROPERTY_RELATED_DOCUMENTS) ]

// New Record/Request

// Set Field [ TO_015____PROPERTY_RELATED_DOCUMENTS::CUSTOMER_ID_MATCH ; $CUSTOMERID ]

// Set Field [ TO_015____PROPERTY_RELATED_DOCUMENTS::Status ; "Emailed" ]

// Set Field [ TO_015____PROPERTY_RELATED_DOCUMENTS::DATE ; $Date ]

// Set Field [ TO_015____PROPERTY_RELATED_DOCUMENTS::DOCUMENT_NAME ; TO_002____Customers::SiteAddressShort &"_" & Substitute ( Get ( CurrentDate ) ; "/" ; "-" )&  ".pdf" ]

// Insert File [ TO_015____PROPERTY_RELATED_DOCUMENTS::DOCUMENT ; “$PATH” ]

// Commit Records/Requests [ With dialog: On ]

// #

// New Record/Request

// Set Field [ TO_015____PROPERTY_RELATED_DOCUMENTS::CUSTOMER_ID_MATCH ; $CUSTOMERID ]

// Set Field [ TO_015____PROPERTY_RELATED_DOCUMENTS::Status ; "Emailed" ]

// Set Field [ TO_015____PROPERTY_RELATED_DOCUMENTS::DATE ; $Date ]

// Set Field [ TO_015____PROPERTY_RELATED_DOCUMENTS::DOCUMENT_NAME ; "Terms_Conditions.pdf" ]

// Set Field [ TO_015____PROPERTY_RELATED_DOCUMENTS::DOCUMENT ; TO_001____PREFERENCES::Terms_Condtions_PDF_Global ]

// Insert File [ TO_015____PROPERTY_RELATED_DOCUMENTS::DOCUMENT ; “$TC_PDF” ]

// Commit Records/Requests [ With dialog: On ]

// Close Window [ Current Window ]

// #

// Insert File [ TO_002____Customers::Quotation PDF ; “$PATH” ]

// #

// Commit Records/Requests [ With dialog: On ]

// Beep

#

Outcomes