Document Generator: Overview of Methods

We are still updating this page

Some data may be missing here — we will fill it in shortly.

Quick navigation: all methods

Currently, there are two scopes for working with the document generator:

  • Methods crm.documentgenerator.*. The results of these methods are displayed in the CRM interface;
  • Methods documentgenerator.*. The results of these methods are only available at the REST level.

Data from one scope cannot be accessed from another:

  • You cannot create a CRM document with a template for REST;
  • You cannot use CRM data when working with methods documentgenerator.*.

The following field types and their modifiers are supported:

  • IMAGE - images;
  • STAMP - seals and signatures;
  • DATE - dates;
  • NAME - names.

The field types Money and Address are implemented within the crm module, so they cannot be used in the REST of this module. If you need to display such data, you will have to pass it in a pre-formed format.

It is possible to use arrays for insertion into tables and repeating blocks.

Differences in Method Parameters Across Scopes

“Internally,” the methods are identical. In fact, the methods crm.documentgenerator.* call the methods documentgenerator.* after preprocessing the parameters. However, there are several differences:

  • For the input of methods crm.documentgenerator.*, you need to pass the ID of the CRM entity type instead of provider names (parameter entityTypeId);
  • For the input of methods crm.documentgenerator.*, you need to pass the parameter entityId instead of the value parameter - the ID of the CRM entity.

Templates

All templates and documents created by this API are tied to the REST module. You cannot access templates and documents from other modules through the documentgenerator scope. Therefore, the moduleId in the template data will always be rest. Even if you specify another module in add or update, it will not be changed.

Only two providers are available for REST:

  • Bitrix\DocumentGenerator\DataProvider\Rest - must always be specified as the provider for the template
  • Bitrix\DocumentGenerator\DataProvider\HashDataProvider - used for passing data into tables / repeating blocks

The binding of the template to the user is not considered by the REST methods. However, it can be utilized on the application side.

Numbering

For working with numberers, there are methods documentgenerator.numerator.*, described here. It should be noted that through this scope, you can access all numberers for documents, including those that work in CRM. However, you can only update/delete the numberer that was created through REST.

List of Regions

Each template is tied to a specific country. The list of countries is fixed and currently consists of:

  • us - United States
  • by - Belarus
  • kz - Kazakhstan
  • ua - Ukraine
  • br - Brazil
  • mx - Mexico
  • de - Germany
  • uk - United Kingdom
  • pl - Poland

Starting from version documentgenerator 18.6.1, it became possible to add your own regions. A separate section was created for managing them.

Summary

What can be done?

  • Create documents based on templates in .docx file format;
  • Insert lists with an arbitrary number of items into the template via tables or repeating blocks;
  • Insert images into the template, including from lists;
  • Insert fields in HTML format with partial preservation of formatting;
  • Create documents, send them, and track views without user involvement (via Automation rules).

What cannot be done?

  • Insert multiple values for the file type field;
  • Insert tables and images from HTML;
  • Insert vector images;
  • Formatting transfer is not fully executed.

Overview of Methods and Events

Documents

Method

Description

documentgenerator.document.add

Creates a new document based on a template

documentgenerator.document.delete

Deletes a document

documentgenerator.document.enablepublicurl

Enables/disables a public link to the document

documentgenerator.document.getfields

Retrieves a list of document fields

documentgenerator.document.get

Retrieves a document by its identifier

documentgenerator.document.list

Retrieves a list of documents

documentgenerator.document.update

Modifies an existing document

Numbering

Method

Description

documentgenerator.numerator.add

Adds a numberer

documentgenerator.numerator.delete

Deletes a numberer

documentgenerator.numerator.get

Retrieves a numberer by its identifier

documentgenerator.numerator.list

Retrieves a list of numberers

documentgenerator.numerator.update

Modifies a numberer

Regions

Method

Description

documentgenerator.region.get

Returns information about a region by its identifier

documentgenerator.region.list

Returns a list of regions, both default and custom

documentgenerator.region.delete

Deletes a region

documentgenerator.region.add

Adds a new region

documentgenerator.region.update

Updates an existing country

Roles

Method

Description

documentgenerator.role.get

Provides information about a role and its access permissions

documentgenerator.role.list

Returns a list of roles without their access permissions

documentgenerator.role.delete

Deletes a role

documentgenerator.role.add

Adds a new role

documentgenerator.role.update

Updates roles

documentgenerator.role.fillaccesses

Sets a set of roles and their bindings

Templates

Method

Description

documentgenerator.template.add

Uploads a new document template

documentgenerator.template.update

Updates an existing document template

documentgenerator.template.get

Returns a document template by its identifier

documentgenerator.template.list

Returns a list of document templates by filter

documentgenerator.template.delete

Deletes a document template

documentgenerator.template.getfields

Returns a list of document template fields