Views: 1080 (Data available since 06.02.2017)

If a developer wants to use the business process functionality to its fullest, additional possibilities of the functionality will be required. For example, the output of any messages into the business process log.

Let us assume that the manager’s determination from the lesson “Manager’s ID determination” is used, or the request text just needs to be displayed in the log.

There are two solutions for this: display in the log from the activity PHP code or creation of own activity Record to log. Let us consider both options.

PHP Code

Let us assume that while creating a business process the user types a text of a request which is saved in the Text. variable. In order to display the value of this variable, just add the following query into the PHP code activity:

$rootActivity = $this->GetRootActivity();
$this->WriteToTrackingService($rootActivity->GetVariable("Text")); 

Creating an Activity

Create necessary folders from the website root:

  • bitrix\activities\custom
  • bitrix\activities\custom\logactivity
  • bitrix\activities\custom\logactivity\lang\en

Create the following files in the folder /logactivity/:

  • logactivity.php

    <?
    if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED!==true)die();
    
    class CBPLogActivity
       extends CBPActivity
    {
       public function __construct($name)
       {
          parent::__construct($name);
          $this->arProperties = array(
             "Title" => "",
          );
       }
    
       public function Execute()
       {
          $rootActivity = $this->GetRootActivity();
          $this->WriteToTrackingService($rootActivity->GetVariable("Text"));
    
          return CBPActivityExecutionStatus::Closed;
       }
    
    }
    ?>
  • .description.php

    <?
    if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED!==true) die();
    
    $arActivityDescription = array(
       "NAME" => GetMessage("BPMA_DESCR_NAME"),
       "DESCRIPTION" => GetMessage("BPMA_DESCR_DESCR"),
       "TYPE" => "activity",
       "CLASS" => "LogActivity",
       "JSCLASS" => "BizProcActivity",
       "CATEGORY" => array(
          "ID" => "other",
       ),
    );
    ?>

Create the file logactivity\lang\en\.description.php:

<?
$MESS ['BPMA_DESCR_NAME'] = "Record to log";
$MESS ['BPMA_DESCR_DESCR'] = "Recording a message into Log";
?>

Now the business process designer has a new activity Record to log in the section Other, and the activity just records the value of the variable Text into the log.



Courses developed by «Bitrix», Inc.