Solving the error of importing business processes with custom activities in Bitrix24 by Avivi

28 November 2022

next article
Slava Nahnybida

PR manager

Slava Nahnybida
Solving the error of importing business processes with custom activities in Bitrix24 by Avivi

Our company is often approached by clients who have the same problem with custom activities. This is a fairly common phenomenon after the introduction of additional functionality in the cloud service and on-premise version of Bitrix24, when developers use Rest API methods. It is not easy to find solutions for this bug in Google. But we have such a good development experience for Bitrix24 that we have already found out the reason and found a universal solution for importing a custom activity (a set of basic methods that are necessary for any activity. Can or should be overridden in the inheriting class).

1e672ba78e2102099397f2591d3d9a8a.png

Next, we share exclusively our own experience, gained and tested in practice many times. If the solution helps you too, we will be happy to tell you some more important details or solve the problem of your Bitrix24. So we have a template backup. We import it and get "Import error" in response. The thought creeps in that maybe there is something in the templates that ties it to the Portal or a specific application. Let's take a look at this template.

We open it in any editor, we see something like this:

1d3b95e97185bebe1a95f468bc5f47d2.png

Everything is coded and it is absolutely impossible to work with such data. Therefore, the first thing you need to understand is how export or import works. Let's look at the template processing page in Bitrix24 on-premise:

9fb54db2c6547b7af6f01a279ac81536.png

The bitrix component is placed here: crm.config.bp. We start editing: we find the bitrix component call there: crm.config.bp.edit, then bizproc.workflow.edit. Templates are imported and exported using the CBPWorkflowTemplateLoader :: ImportTemplate and CBPWorkflowTemplateLoader :: ExportTemplate methods, respectively. Now it becomes painfully clear what was encrypted and how to deal with it. After studying them, we understand what kind of gills they were and how to process our templates now.

To open the template, read its contents: use gzuncompress() and then unserialize(). Now we have an array with a complete description of all activities of our business-process:

5ecafddea8e88084cca4bac91f1f9787.png

For the keyword rest, we define arrays of descriptions of our custom:

41c3e4f68b93b61512d6189f056af77e.png

We perform the same operations with the exported template from the current version of CRM, or rather, from the place where it is not possible to import the business process. We find the description of rest activity, look at the differences:

  d0493f09cdcc9fc123631ecdc6bdf3f7.png

In addition to [Type], there is also [Name] in the field, but as practice shows, [Type] is quite enough. We change it to the value of the new template everywhere we meet. We carry out the reverse procedure: we apply serialize() and gzcompress() to the final array, we get a new template that is now successfully imported. Now, you can effortlessly transfer the business processes we need from one CRM to another.

Don't forget to share the article with a familiar Bitrix24 developer or integrator :)

Get more with Avivi!


Similar articles
Apply for a consultation

We will reach out to within 10 minutes