Solving the error of importing business processes with custom activities in Bitrix24 by Avivi
28 November 2022
next articleOur 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).
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:
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:
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:
For the keyword rest, we define arrays of descriptions of our custom:
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:
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 :)
We will reach out to within 10 minutes