Document Generation with Date and Name Modifiers

We are still updating this page

Some data may be missing — we will complete it soon.

The description of document modifiers is available on helpdesk.

Using modifiers for dates and names through REST is not mandatory - the input data can be pre-formatted by the application itself. However, it can be convenient. Therefore, REST provides the option to use modifiers. To do this, you need to pass the corresponding field type in fields. Additionally, in fields, you can pass the default format using the key FORMAT. If a modifier is specified for this field in the template itself, the template modifier will be applied.

Date

To ensure that modifiers work for date-type fields, they must be passed in the following format:

  • in values, the date should be provided in atom format (as in all methods)
  • in fields, TYPE = DATE
  • also in fields, you can pass the default modifier using the key FORMAT['format'] (just like in the template)

Name

To ensure that modifiers work for name-type fields, they must be passed in the following format:

  • in values, the name should be provided as an array
[
            'NAME' => 'Ian', // first name
            'LAST_NAME' => 'Smith', // last name
            'SECOND_NAME' => 'Peter', // middle name
            'GENDER' => 'M', // gender
        ]
        

The GENDER key can explicitly specify the gender (M - male, F - female). If the gender is not specified, the module will attempt to determine it based on the middle name. If the middle name is not provided, the gender will not be determined, and declension will not work.

  • in fields, TYPE = NAME
  • in fields, you can pass the default format using the key FORMAT['format']
  • in fields, you can pass the default case using the key FORMAT['case']
$data = [
        	'templateId' => 203,
        	'providerClassName' => 'Bitrix\\DocumentGenerator\\DataProvider\\Rest',
        	'value' => 1,
        	'values' => [
        		'SomeDate' => '2018-10-10T14:30:18+02:00', // value provided in atom format
        		'SomeName' => [ // name provided as an array
        			'NAME' => 'Vladislav',
        			'LAST_NAME' => 'Gorelkin',
        			'GENDER' => 'M',
        		],
        	],
        	'fields' => [
        		'SomeDate' => [
        			'TYPE' => 'DATE',
        			'FORMAT' => [
        				'format' => 'd f Y H:i', // output format
        			],
        		], // field type - date
        		'SomeName' => [
        			'TYPE' => 'NAME',
        			'FORMAT' => [ // here you can pass the default field format
        				'case' => 0, // case code
        				'format' => '#NAME# #LAST_NAME#' // output format
        			]
        		], // field type - name
        	]
        ];
        $url = $webHookUrl.$prefix.'.document.add/';