Controlling File Distribution
← Setting Up Invoice Distribution
JustOn Billing & Invoice Management generates PDF documents when finalizing invoices, dunning reminders and account statements. With this respect, JustOn provides a flexible control over how these documents are created and where they are put.
Possible scenarios include, among others,
- Defining a specific naming scheme for invoice PDF files
- Storing PDF copies of all invoices of a single invoice run in the same location
- Generating multiple PDF documents from a single invoice to be stored in different locations, from where these copies can be moved to an external archiving system, printed to paper, or attached to invoicing emails
Export Settings or File Distribution?
JustOn Billing & Invoice Management uses the custom settings Export Settings and File Distribution to control the output of produced documents. It may be hard to tell which to apply. Remember that the two settings impact different aspects:
- Export Settings records control what to export – invoice and bookkeeping data CSV files or SEPA XML files.
- File Distribution settings control the output location of any produced files, be it PDF files for finalized invoices, dunning reminders and account statements, or exported CSV and XML files.
That is, your use cases determine which settings to use:
- File export
-
If you export data to CSV files for accounting systems or to SEPA XML bank transfer orders, you need appropriate Export Settings records.
Exporting files (applying Export Settings) to the default location - File location
-
If you want produced PDF files for finalized invoices, dunning reminders and account statements to be output in a specific location (other than the group Owned by me in Salesforce Files), you need a corresponding File Distribution setting.
Defining a specific output location using a File Distribution setting - File export and file location
-
If you export data to CSV files for accounting systems or to SEPA XML bank transfer orders, you need appropriate Export Settings records. If you want the exported files to be output in a specific location, you need, in addition, a corresponding File Distribution setting.
To combine the two settings, the
Name
of the file distribution record must be specified as theTarget
in the export settings record.
Exporting files (applying Export Settings) to a specific location (applying File Distribution)
Note
Be aware that the custom setting PDF Name does not modify the file names for the regular PDF file generation on invoice or statement finalization. This setting is used to determine the name for PDF files subject to the ZIP download.
File Distribution Information
The custom setting File Distribution controls the PDF generation and distribution.
The following fields are available:
Field | Possible Values | Description |
---|---|---|
Name | string | A unique name for the custom setting record. Specifies the name of the target folder when uploading exported files to Amazon S3 or Google Drive or saving exported files in Salesforce libraries and folders (to be set in the Target field of an Export Settings record). |
Active (checkbox) | true false |
Specifies whether to use this distribution target or not. |
Backend | Invoice Account GoogleDrive AmazonS3 Folder |
Specifies the distribution target. Backends are either target records (invoices or accounts) in your Salesforce org that are linked to the PDF file, cloud storage services (Amazon S3 or Google Drive) for storing the documents, or existing libraries and folders in Salesforce Files. |
ON_Opportunity__c ON_Contract__c |
As a specific backend use case, you can define the API name of an ID field (master-detail, lookup, formula) on the invoice that links to a specific object. On PDF generation, JustOn creates an attachment on the record referred to by the ID. | |
Draft Folder (checkbox) | true false |
If checked, the distribution target will contain draft invoices only. |
Link on Invoice (checkbox) | true false |
For cloud storage services (Amazon S3 or Google Drive), specifies whether to link the PDF documents of this distribution target in the invoice. |
Path | <string> specifying a library/folder location |
For the Folder backend, specifies the complete path to the intended target location as set up in Salesforce Files. |
PDF Name | <string> composed of placeholders and a file ending |
For the InvoicePDF use case, specifies the naming pattern used for the file name of invoice and dunning PDF documents to be generated.The allowed characters include the alphanumeric characters a-z A-Z 0-9 as well as the underscore _ and hyphen - characters.The pattern can include placeholders to insert dynamic content retrieved from the invoice record, like the creation date of the invoice. As a file distribution target can aggregate PDF invoices generated with different invoice runs, you may want the PDF name to be unique for each invoice. Unique names can be easily achieved by including the [InvoiceID] placeholder in the name pattern.Note that even if the specified pattern does not create unique PDF names, the PDF documents will not be overwritten between invoice runs since Salesforce internally uses a different naming scheme to avoid naming conflicts. That is, if desired, you can give all invoices the same name, like invoice.pdf .If empty, defaults to [InvoiceDate]_[InvoiceNo]_[AccountName].pdf . |
Print Folder (checkbox) | true false |
If checked, only invoices marked with Print Invoice are saved to this distribution target. |
Select Condition | <conditionExpression> |
For the InvoicePDF use case, specifies a condition to restrict the selection of invoices, account statements or dunning reminders that are copied to this folder (a condition expression as used in an SOQL WHERE clause, like GrandTotal__c >= 0 ).Make sure to query only fields that are available on both invoices (ONB2__Invoice__c) and statements (ONB2__Dunning__c). For details, see SOQL WHERE clause in the Salesforce Help. This setting enables you to distribute the PDF documents over multiple folders. For example, you can define separate folders for invoices and credits. In this case, the credit folder has a select condition of GrandTotal__c < 0 , and the invoice folder has a select condition of GrandTotal__c >= 0 . All fields of the invoice and its related objects are accessible. If left empty (default), all invoice PDFs are included.Note that every unique select condition produces an additional query during the PDF creation. Therefore, JustOn recommends to reduce the number of different filters to a minimum. Using exactly the same filter in multiple folders, however, adds only a single query. |
Use Case | InvoicePDF Export |
Specifies the intended use case for the distribution target:InvoicePDF for storing PDF files (invoices, account statements, dunning reminders), default if left emptyExport for exported invoice/booking details CSV or SEPA XML filesJustOn supports the use case Export with the backends AmazonS3 , GoogleDrive and Folder only. |
Example: Custom name for invoice PDF
Assume you just want to modify the name of a produced invoice PDF file, keeping the files in the default location. Create this setting record:
Field | Value |
---|---|
Backend | Invoice |
Name | InvoicePDFname |
PDF Name | [AccountName]_Invoice_[InvoiceNo].pdf |
Active | true |
This produces an invoice PDF with a name like JustOn_Invoice_201700018.pdf
, located on Salesforce's Files tab in the group Owned by me, and links the file with the corresponding invoice record.
Example: Account as file distribution target
Assume that you want to set up the account as the file distribution target. You can apply the following settings:
Field | Value |
---|---|
Backend | Account |
Name | Account |
Active | true |
This produces an invoice PDF using the default name pattern ([InvoiceDate]_[InvoiceNo]_[AccountName].pdf
) and adds a link to the Salesforce file from the corresponding account record.
Example: Upload CSV export files to Amazon S3
The following example shows a file distribution intended to upload CSV export files to Amazon S3:
Field | Value |
---|---|
Backend | AmazonS3 |
Name | my-export:eu-central-1 |
Use Case | Export |
Active | true |
With the use case Export
, the fields Link on Invoice
, Print Folder
, Draft Folder
, PDF Name
and Select Condition
are ignored and can therefore be left empty.
Example: Save files to a Salesforce library/folder
Assume you have created a library/folder structure in Salesforce Files like
Library 1
↳ Folder A
↳ Folder B
Library 2
↳ Folder Y
↳ Folder Z
Now you want to store produced invoice files in Folder Z. You use this file distribution setting:
Field | Value |
---|---|
Name | Folder Z |
Active | true |
Backend | Folder |
Path | Library 2/Folder Y/Folder Z |
This produces PDF files using the default name pattern and stores them in Salesforce Files under Library 2/Folder Y/Folder Z
. For details, see Storing Files in Salesforce Libraries and Folders.
Example: Save invoices and account statements to different Salesforce library folders
Assume you want to save PDF files for invoices and account statement to different folders in Salesforce Files. To this end, you have created the the following library/folder structure:
Documents
↳ Invoices
↳ Account Statements
Assume, in addition, that dunning reminders (First reminder
and Second reminder
) are not to be saved to either of the two directories.
To distribute the PDF files, you need two file distribution settings:
- Setting 1
-
Field Value Name Invoices
Active true
Backend Folder
Path Documents/Invoices
Select Condition ONB2__Type__c NOT IN ('Account Statement','First reminder','Second reminder')
- Setting 2
-
Field Value Name Account Statements
Active true
Backend Folder
Path Documents/Account Statements
Select Condition ONB2__Type__c = 'Account Statement'
Defining File Distribution
Depending on your organization's requirements, you must define one or more file distribution targets.
Info
You can create multiple file distribution configurations.
To set up a file distribution target:
-
Click to enter Setup, then open Custom Settings.
In Salesforce Lightning, navigate to Custom Code > Custom Settings.
In Salesforce Classic, navigate to Develop > Custom Settings.
-
Click Manage in the row of File Distribution.
- Click New.
-
Specify the details as necessary.
The mandatory information include the name and the backend.
For details, see File Distribution Information.
-
Click Save.
Enabling PDF Redistribution
Certain business use cases may require (re-)distributing existing PDF documents to a file distribution target, for example, in case the automatic distribution has failed or there is a new file distribution target to be populated. To this end, JustOn Billing & Invoice Management provides the custom button Distribute PDF. You can select records from list views and then use this button to distribute the corresponding PDF files to a (configurable) file distribution target.
Note
Use the redistribution function with caution. JustOn Billing & Invoice Management does not check the selected file distribution target for existing files, so distributing the same files to the same targets produces duplicates, which may consequently have unwanted effects.
To enable this option, you can add the button Distribute PDF to the following list views:
- Invoices List View
- Invoice Run Layout
- Dunnings List View
- Statement Run Layout
Draft Handling
JustOn Billing & Invoice Management allows user to generate PDF files for draft invoices for review or testing purposes. For details, see Creating Draft PDF.
With this respect, JustOn provides for the strict separation of Draft
invoices from finalized invoices (Open
, Paid
, Settled
, Canceled
). To this end, the redistribution feature includes the option Only draft folders and invoices/dunnings
. Together with the File Distribution setting Draft Folder
(see File Distribution Information), this facilitates distributing either Draft
invoices or finalized invoices.
Invoice Status to Consider | Draft Folder Setting |
Only Draft Option |
---|---|---|
Open , Paid , Settled , Canceled |
false |
false |
Draft |
true |
true |
Info
Selected folders with non-matching draft settings are ignored.
Using Invoices List View or Dunnings List View
To add the button Distribute PDF to the Invoices List View or Dunnings List View, proceed as follows:
- Navigate to the object management settings of the Invoice or Dunning object.
- Click Search Layouts.
- Click Edit in the row of the Invoices List View or Dunnings List View, respectively.
- In the Custom Buttons section, move
Distribute PDF
to the Selected Buttons column. -
Click Save to save the modified page layout.
For help about modifying layouts, see Managing Pages.
Using Invoice Run Layout or Statement Run Layout
To add the button Distribute PDF to the Invoice Run Layout or Statement Run Layout, proceed as follows:
- Navigate to the object management settings of the Invoice Run or Dunning Run object.
- Click Page Layouts.
- Click Edit in the row of the Invoice Run Layout or Dunning Run Layout, respectively.
- Scroll to the Invoices list in the Related Lists section and click to open the list properties.
- Open the Buttons section.
-
Under Custom Buttons, move
Distribute PDF
to the Selected Buttons column.
Adding a custom button to a related list -
Click OK to save the list properties.
-
Click Save to save the modified page layout.
For help about modifying layouts, see Managing Pages.
Storing Files in Salesforce Libraries and Folders
JustOn Billing & Invoice Management can store produced files – PDF files (invoices, account statements, dunning reminders) and exported invoice/booking details CSV or SEPA XML files – in libraries and folders. This allows for organizing your files according to your business needs.
Valid Library/Folder Paths
JustOn makes use of existing libraries and folders as set up in Salesforce Files. It does not create libraries or folders, however.
In order to allow JustOn accessing your libraries and folders, you need to model the path to your target, starting from your Files Home as root. Assume the following library/folder setup:
Library 1
↳ Folder A
↳ Folder B
Library 2
↳ Folder Y
↳ Folder Z
Assuming this example, the following paths are valid:
Intended Target Location | Path (File Distribution Setting) | Description |
---|---|---|
Library 1 | Library 1 |
root a library |
Folder B | Library 1/Folder B |
a folder in a library |
Folder Z | Library 2/Folder Y/Folder Z |
a (nested) sub folder |
File Distribution Setting
You enable the file distribution to libraries and folders using a corresponding File Distribution custom setting: The Backend
field of the record must be set to Folder
.
Field | Example Value | Description |
---|---|---|
Name | Folder Z |
A unique name for the custom setting record. Can be referred to using the Target field of an Export Settings record. |
Active | true |
Specifies whether to use this distribution target or not. Only active distribution targets are considered. |
Backend | Folder |
Specifies the distribution target. Folder enables the library/folder-based backend. |
Path | Library 2/Folder Y/Folder Z |
Specifies the complete path as set up in Salesforce Files. |
Use Case | empty | Export |
Specifies the intended use case for the distribution target: empty for storing PDF files (invoices, account statements, dunning reminders) Export for exported invoice/booking details CSV or SEPA XML files |
Implementation Restrictions
The following restrictions apply:
-
You can store a file only once per library in one (sub) folder. You can, however, save a file in multiple libraries.
Assuming the example above: A file can reside either in Folder A or in Folder B, but not in both, and in Folder Y or Folder Z.
-
When you share a file with a library, the library settings define whether you can share the file using a public link.
Review the library permissions and enable the
Deliver Content
permission.JustOn Billing & Invoice Management can generate public links to the produced PDF files. Make sure to test this functionality carefully together with the
Folder
backend.
Info
While we are confident that the Folder
backend enhances JustOn's usability and operational excellence, we recommend to first test the feature in a Sandbox environment with respect to your business use cases.