Documents templates contain symbolic codes that are used instead of different data. For example, {DocumentCreateTime} code is used in a document template and gets replaced by actual document creation time in a document print form.
But there are different date formats or address formats, how can you select a specific date format that you need?
Don't worry, you can modify symbolic codes in documents templates and solve this problem.
How it works
You can add specific symbols after ~ to symbolic code to change the data format. For example, {DocumentCreateTime~d.m.Y h:s}
You can modify symbolic codes for dates, addresses, names and money amounts.
Date and time
By default, the date format in a document template is the same as the country that this document template belongs to. Let's modify the symbolic code that is used for adding document creation time to a document print form.
Possible date and time formats
- d.m.y - 30.08.18
- d.m.Y - 30.08.2018
- j, n, Y - 30, 8, 2018
- H:i:s - 15:07:06
- Y-m-d g:i:s a - 2018-08-30 3:07:06 pm
- F j, Y, G:i - August 30, 2018 15:07
You can read more about possible date and time formats in the article.
Here's how the print form looks now:
Name
You can modify the name format by adding specific words to symbolic codes. For example, the symbolic code {FormattedName~Format=#TITLE# #NAME# #SECOND_NAME_SHORT# #LAST_NAME#} will be replaced by salutation, first name, the first letter of the second name and last name in the print form.
Name format parameters
- #TITLE# - salutation
- #NAME# - first name
- #LAST_NAME# - last name
- #SECOND_NAME# - second name
- #NAME_SHORT# - the first letter of the first name
- #LAST_NAME_SHORT# - the first letter of the last name
- #SECOND_NAME_SHORT# - the first letter of the second name
Address
By default, the address format in a document template is the same as the address format used in the country that this document template belongs to. But we can modify the address symbolic code and use, for example, North American address format although the document template is bound to the UK.
Address formats and separators
- 1 - Europe
- 2 - UK
- 3 - North America
- 4 - Russia (Street-->Country)
- 5 - Russia (Country-->Street)
- 1 - comma
- 2 - no separator
- 3 - line break
Here's how the document print form will look like after address symbolic code modification:
Money amounts
For money amounts, you can modify symbolic code so that zeros after dot and currency will be shown in a print form of a document.
Money amounts parameters
- WZ (With zeros) - if you select Y value, zeros after dot are shown. For example, 12.00 instead of 12.
- NS (No sign) - if you select N value, currency sign is added. If you select Y value, currency sign is not shown.
For example, let's modify the {TotalSum} symbolic code so that zeros after dot will be shown and currency sign will be added:
Here's how the document print form will look like:
Phone number
You can specify phone number format by adding a specific symbolic code after format. For example:
{ClientPhone~format=E.164}
Available formats:
- E.164 - +12122191234
- International - +1 212 219-12-34
- National - 1 (212) 219-12-34
A specific product, tax or contact from the list
Some data is added to the document as a list. For example, taxes, products or contacts.
You can add to a document a specific item from the list. Just use the symbolic code:
{ProductsProductName}
By default, the first item from the list will be added to the document.
If you need to add an item that is not first in the list, just add index to this symbolic code. For example, this symbolic code will add the third item:
{ProductsProductName~index=2}
"Multiple" fields
In Bitrix24 CRM, fields can be marked as Multiple. That means that this field can have multiple values at the same time. For example, Phone, Email, Messeneger fields or any custom field marked as Multiple.
Use the symbolic code mfirst to add "multiple" filed values to the document:
- mfirst=y - add the first value
- mfirst=n - add all the values
For example:
{TestField~mfirst=n}
By default, values are separated by comma. Use the symbolic code mseparator to select a separator - cooma (1) or line break (2):
{TestField~mseparator=2}
Listing all products, contacts or taxes from the list
For example, you can list all the products in the document. Just add all=y to the corresponding symbolic code:
{ProductsProductName~all=y}
Instead of a comma, you can use a line break as a separator by adding mseparator=2 to the symbolic code:
{ProductsProductName~mseparator=2,all=y}
Text case (from documentgenerator 22.200.0 version)
One of the frequent requests is a modifier to change the text case.
For example, {DocumentCreateTime~format=d F Y}
displays the name of the month with a capital letter.
Now you can add letterCase
modifier to any field to change the text case.
The modifier can take the following values:
upper
— upper case,
lower
— lower case,
title
— upper case for the first letter of each word.
Recommended articles