Views: 10887
Last Modified: 16.09.2014

Let us consider examples on how to display some variables in the log using PHP code.

List Type Variable

Let us assume that the following List type variable in the DB business process is used:

[Database 1]DB1
[Database 2]DB2
[Database 3]DB3

The value of this variable must be displayed in the log (it also admits multiple values). The display must be arranged as a search of values:

$rootActivity = $this->GetRootActivity();
$list = $rootActivity->GetVariable("DB");
foreach ($list as $k => $v)
   $str = $str." ".$v;
$this->WriteToTrackingService("The following databases are selected: ".$str);

The Variable of the Linked-to-User Type

Let us assume that the Manager variable is used, its type is Linked-to-User, and it is represented by a string user_145, where the number is the user ID. Let us display its value as the last name and first name.

$str = $rootActivity->GetVariable("Manager");
$str = str_replace("user_", "", $str);
$buf = CUser::GetByID(intval($str))->Fetch();
$this->WriteToTrackingService(" Supervisor:".$buf['NAME']." [".$buf['ID']."]");

Courses developed by Bitrix24