Renaming invoice/quotation PDFs

Prev Next

José is happy with the progress of the PDF templates. The only thing he would like to change is the name given to the PDFs sent to customers.

Note: This article is only a suggestion/inspiration for PDF renaming. You need to adapt this procedure to your needs.

Creation of fields

Please create this field to use for the feed and to compose the future name of your PDFs according to your needs.

  • Frisbii_Ref_PDF:

Formula (text)
Object: Invoice
'Prefix desired'+sofactoapp__Facture__r.Reference_facture__c


Creating the flow

To make it easier to work with and read the feed, we recommend that you follow a naming scheme like this:

Text variable

VarT_

File Load

FL_

Update Record

UR_

Frisbii Variable

SoV


We advise you to read this article about good practices for the naming of flows:
Configuration Standards For Salesforce Visual WorkFlow


Procedure

  1. Go to Setup > Process Automation > Flows

  2. Click on the New Flow button

  3. Select Autolaunched Flow

A - Creating resources: Variables

  1. In the Flow Builder, click on Manager ant then on the New Resource button

  2. Fill in the following fields:

  • Resource type: Variable

  • API name: VarT_DocumentID

  • Data type: Text
     

  1. Click on Done

  2. Repeat steps 4 to 6 for the variable VarT_FacturePDFId

  • Resource type: Variable

  • API name: VarT_FacturePDFId

  • Data type: Text

  • Availability Outside the Flow: check Available for input

B - Creating Resources: Record Variables (Unique)


8. Click on Manager and then on the New Resource button
9. Fill in the following fields:

  • Resource type: Variable

  • API name: SoV_Document

  • Data type: Record

  • Object: Document

10. Click on Done.
11. Repeat steps 8 to 10 for the variable SoV_FacturePDF

  • Resource type: Variable

  • API name: SoV_FacturePDF

  • Data type: Record

  • Object: Invoice PDF


C) Creating Resources: Formulas

12. Click on Manager and then on the New Resource button
13. Fill in the following fields:

  • Resource type: Formula

  • API Name: Name

  • Data type: Text

  • Formula:

"(NameDesired)"+{!SoV_Document.Name}

14. Click on Done.
15. Repeat steps 8 to 10 for the formula NameFacturesPDF

  • Resource type: Formula

  • API name: NameFacturesPDF

  • Data type: Text

"(NameDesired)"+{!SoV_Document.Name}

This is what you need to see:

D) Get Records

16. Click on the Elements tab
17. Drag and drop the small pink Get Records icon into the right hand part of the window.
18. Enter the following values in the New Get Records window that opened

  • Find Salesforce records and store their field values in flow variables.

    • Label: FL_FacturePDF

  • Get Records of This Object

    • Object: Invoice PDF

  • Filter Invoice PDF Records

    • Condition Requirements: All Conditions Are Met (AND)

    • Field: Record Id

    • Operator: Equals 

    • Value: {!VarT_FacturePDFId} (Pay attention to the spaces in front or behind the tag!)

  • Sort Invoice PDF records :

    • Sort Order: Not Sorted

    • How Many Records to Store: Only the first record

    • How to Store Record Data: Choose fields and assign variables (advanced)

    • Where to Store Field Values: Together in a record variable

  • Select Variable to Store Invoice PDF

    • Record: {!SoV_FacturePDF}

  • Select Invoice PDF Fields to Store in Variable (click on + Add Field) 

    • Field: ID

    • Field: type 'DocumentID' and select 'sofactoapp__DocumentId__c'

    • Field: Name

    • Field: type 'Draft' and select 'sofactoapp__Facture_brouillon__c'

    • Field: Frisbii_Ref_PDF__c

  • Check the box: When no records are returned, set specified variables to null.

19. Click on Done.
20. Repeat steps 16 to 19 for the Get Records element FL_Document by filling in the fields as shown here:

  • Find Salesforce records and store their field values in flow variables.

    • Label: FL_Document

  • Get Records of This Object

    • Object: Document

  • Filter Document Records 

    • Condition Requirements: All Conditions Are Met (AND)

    • Field: Id

    • Operator : Equals

    • Value: {!SoV_FacturePDF.sofactoapp__DocumentId__c} (Pay attention to the spaces in front or behind the tag!)

  • Sort Document Records:

    • Sort Order: Not Sorted

    • How Many Records to Store: Only the first record

    • How to Store Record Data: Choose fields and assign variables (advanced)

    • Where to Store Field Values: Together in a record variable

  • Select Variable to Store Document

    • Record: {!SoV_Document}

  • Select Document Fields to Store in Variable

    • Field: ID

    • Field: Name

  • Check the box: When no records are returned, set specified variables to null.

E) Update records

21. Click on the Elements tab
22. Drag and drop the small pink Update Records icon into the right hand part of the window.
23. Enter the following values in the New Update Records window that opened

  • Update Salesforce records using values from the flow.

    • label: UR_Document Name

  • How to Find Records to Update and Set Their Values

    • Check: Specify conditions to identify records, and set fields individually

  • Update Records of This Object Type

    • Object: Document

  • Filter Document Records

    • Condition Requirements for Records to Update: All Conditions Are Met (AND)

    • Field: ID

    • Operator: Equals 

    • Value: {!SoV_FacturePDF.sofactoapp__DocumentId__c} (Pay attention to the spaces in front or behind the tag!)

  • Set Field Values for the Document Records

    • Field: Name

    • Value: {!SoV_FacturePDF.Frisbii_Ref_PDF__c} (Pay attention to the spaces in front or behind the tag!)

24. Click on Done.
25.  Repeat steps 21 to 24 for the Update Records element UR_NameFacturesPDF by filling in the fields as shown here:

  • Update Salesforce records using values from the flow.

    • Label: UR_NameFacturesPDF

  • How to Find Records to Update and Set Their Values

    • Check: Specify conditions to identify records, and set fields individually

  • Update Records of This Object Type

    • Object: Document

  • Filter Document Records

    • Condition Requirements for Records to Update: All Conditions Are Met (AND)

    • Field: ID

    • Operator: Equals 

    • Value: {!VarT_FacturePDFId} (Pay attention to the spaces in front or behind the tag!)

  • Set Field Values for the Document Records

    • Field: Name

    • Value: {!SoV_FacturePDF.Frisbii_Ref_PDF__c} (Pay attention to the spaces in front or behind the tag!)

26. Save the stream by clicking on the Save button at the top right of the window.
27. Click on the Activate button.

Testing automation

Let's not forget to test our process.

Preparation

First, make sure you have an invoice available that meets the criteria

  • Invoice State is issued

Procedure

  1. Create a PDF manually by clicking on the Create PDF button

  2. Then click on Save PDF

  3. Click on Validate

  4. Look in the related list invoice PDF

  • First the PDF is created with the automatic name

  • Then the PDF is renamed

Warning: As some cache problems may occurs in Salesforce, please refresh the page several times.

If you have set up automations to create the PDF, please do the same test by replacing steps 1 to 3 of the procedure with this procedure.