Create a Unique Invoice Number
Available on all tiers:
Contents
About
Many organizations use TrueContext to generate documents like Invoices, Work Orders, and Site Inspections, which may require a unique identifier such as an invoice number. Though the TrueContext-generated Form Submission Reference Number is guaranteed unique and may work as an invoice number for many, some organizations may wish to create their own invoice numbers. Rather than asking users to manually enter an invoice number, or having an admin manually dispatch one, there are a number of ways to dynamically generate a unique number to help your team identify your data records.
To guarantee unique numbers/identifiers, we recommend using either the data record reference number, data record ID, or date/time as part of the expression that you configure.
Form Submission Reference Number vs. Form Submission Identifier
The Form Submission Reference Number is the TrueContext system's unique identifier for a submitted form. It is shown beside each form submission listed in the "Form Submissions" page in the web portal. The reference number is always unique is composed of a string identifying the date the data record was submitted, and the Form Submission Identifier, in the format "yyyyMMD-##########".
The Form Submission Identifier is simply the second part of the Reference Number.
Using Data Reference Expression Language, the Reference Number is referenced with %r, while the identifier is referenced with %r[id].
Case #1: Name Form Submission Documents with an Invoice Number
About
As an administrator, you may wish your PDFs or other documents to use a unique Invoice Number or other ID. This can be configured in the basic Document Settings using DREL.
Configure the Document
The Form Submission Document Filename Expression is normally found in the Document configuration under the Document Basics tab:
Sample Expressions:
- "%a[Customer ID]-%r[id]" will create a filename like "1234567-1810010000"
- "INV-%r" will create a filename like "INV-20140622-1810010000"
Case #2: Create a Unique Invoice Number in the Mobile App
About
Some organizations may wish to create a unique number (like an invoice number) that displays on the device even before a form is submitted (when the data record reference number does not yet exist); perhaps the invoice number is required to be on the form before the customer signs off on it, or the invoice number must be shown in full on the actual document, not just in the document filename.
This can be done using the digit extraction control type, or a combination of digit extraction and string concatenation. The best way to guarantee a unique number is to include a reference to a date/time selector or stamp and use digit extraction to strip non-numeric characters.
Scenario and Desired String
It is easier for you to manage your customers' payments if their invoice number contains their customer number. The desired string in this scenario is: "(Customer Number)-(date, non-numeric characters extracted)".
Configuring the Form
Below is a view of the form builder, showing the questions we will use to create the invoice number:
- A dropdown question - Where the user will select a customer from a list populated by a data source Data sources, also known as "Lookups", are external sources of data that you upload or connect to TrueContext. You can reference this data in a form to populate answers or answer options. Data sources save typing, reduce errors, and make it easy to provide mobile users with only the relevant, most current data.
- A Date/Time Stamp - The input for the digit extraction question
- A digit extraction question - This allows you to format the Date/Time stamp however you prefer.
- A String Concatenation to string it all together and create the invoice number
Customer ID
The question collecting the Customer Number is a dropdown question referencing a data source (of any type, here named "Customer List") that contains a list of customer name in the "Company Name" column and a list of Customer ID's in the "Customer Number" column. below is the list in spreadsheet format.
Your mobile users don't know the customer numbers, so it easiest for them to select the customer name, while having the form actually collect the customer number. In the Data Source configuration section of the dropdown properties, select "Company Name" for the Column displayed in dropdown and "Customer Number" for the Column to use as the answer.
Date/Time and Digit Extraction
No special configuration is required for the Date/Time Stamp itself; just ensure it is before the digit extraction control. The digit extraction control has been configured to extract the date in the following format: yyMMddHHmm
String Concatenation
In String Concatenation Properties, we can link the above fields together and add some static elements for the sake of formatting.
On a Mobile Device
|
Case #3: Create an Invoice Number with the Dispatch Data Destination
About
If your workflow already includes using the Dispatch Data Destination to dispatch data from one user to another, you have a lot of flexibility in building invoice numbers that can appear in the mobile app. It is possible to include the data record reference number or identifier (of the form used to dispatch) in an invoice number shown on the mobile device (in the target form). In fact, Data Reference Expression Language can be used to grab many other identifiers from the metadata of the submitted form, like user ID (%u[id]) or form id (%f[id]) that may be useful in building an invoice number.
Note:The Dispatch data Destination is the only dispatching method that allows the use of Data Reference Expression Language.
String #1: "Form Identifier - Data Record Identifier"
It is possible to build the whole invoice string in your Dispatch Data Destination's "Dispatch Data" section, based entirely on the meta data from the submitted form that created the dispatch, and dispatch the entire invoice number. In this example we will reference the identifier of the Form itself, as well as the data record ID.
*If using this method, you can also include this invoice number in the name of the dispatched form; read about Data Record Naming.
Configure the Data Destination
- Provide the Unique ID of the question in the Target Form where the invoice number should appear. This is case sensitive.
- For the Answers to Dispatch section, enter "%f[id]-%r[id]". This is all in lowercase.
In the Target Form
String #2: "INV(Customer Number)-Data Record ID"
In the "Dispatch Data" section, it is also possible to combine submitted form data with the data record ID to create an invoice number. See Case #2 (above) for details on how to populate the customer number in the initial/dispatching form. Use %a[UniqueID] in the data expression to reference the submitted data from the initial form used to create the dispatch. We'll also add some static text to this string.
Configure the Data Destination
- Provide the Unique ID of the question in the Target Form where the invoice number should appear. This is case sensitive.
- For the Data Expression, enter "INV%a[Customer ID]-%r[id]". This is all in lowercase.
In the Target Form