Views: 2598 (Data available since 06.02.2017)

This action permits you to execute an arbitrary PHP code.

Attention! 1. This action is only available in Bitrix24 Self-hosted version.
2. Only a user with administrator’s rights can set PHP code.

Note: The code must be indicated with no opening or closing tags (<?, ?>).

Action Parameters

Since the meaning of most fields is clear from their names, their description is omitted.

Examples of application

Setting a value for the variable

$this->SetVariable('Variable1', 12345);


Variable1 – identifier of the variable to which a value will be assigned (12345 number).

Entering several users to the User type variable

$this->SetVariable("user", array("user_1", "user_2"));


array("user_1", "user_2") – an array of users in the format user_[user_identifier_in_the_system].

The use of PHP code and values of fields/variables to obtain the name of the infoblock element

$arFilter = Array("IBLOCK_ID" => {=Variable:Variable1_printable}, "ID" => {=Document:PROPERTY_1}); 
$dc = CIBlockElement::GetList(array(), $arFilter, array("NAME"));
$br = $dc->Fetch();
$Pbrr = $br["NAME"];
$this -> SetVariable('Variable2', $Pbrr);


{=Variable:Variable1_printable} – value of the variable containing the infoblock identifier;
{=Document:PROPERTY_1} – field of the document containing the infoblock element identifier;
Variable2 – identifier of the variable which will be assigned the calculated name of the infoblock element.

Conversion of the document field format and its further use

Let us consider an example of conversion of the document field User to an understandable form in order to use it when sending a message:

  1. A variable to store the converted value of the document field should be created in the business process template;
  2. Let us indicate the following in the PHP code action:
    $rsUser = CUser::GetByID({=Document:PROPERTY_USER});
    $arUser = $rsUser->Fetch();
    $this->SetVariable('#Variable_name#', $arUser[NAME].' '.$arUser[SECOND_NAME].' '.$arUser[LAST_NAME]);
  3. After that, we have to use the result of this variable instead of the document field in the block used for notification.

Courses developed by «Bitrix», Inc.