Documentation

Code example

Some examples are provided in the customization section.



Handling the data


Processes
$typesCollection = \Bitrix\Rpa\Model\TypeTable::getList()->fetchCollection();

$typeId = 1; // process ID

$type = Bitrix\Rpa\Driver::getInstance()->getType($typeId);
Stages
$stages = $type->getStages();

$stageId = 1; // stage ID

$stage = $type->getStage($stageId);
Element/items
// stage items with ID higher than 100
$items = $stage->getItems([
    'filter' => [
        '>ID' => 100,
    ]
]);

// element with ID = 1 process $type
$item = $type->getItem(1);

Updating elements


When only element data must be updated

For example, for one or another reason, some field value must be reset, without launching automation rules and saving in history.

In this case, this element must be handled directly

$typeId = 1;
$itemId = 1;
$fieldName = 'UF_RPA_1_MY_FIELD';

$item = Bitrix\Rpa\Driver::getType($typeId)->getItem($itemId);

$item->set($fieldName, null);
$item->save();

When the same must be done only with sending of pushes and saving in history, use the following command:

$command = Bitrix\Rpa\Driver::getFactory()->getUpdateCommand($item);
// disable all checks and automation rules launching. Creates an update push, history and timeline entries.
$command->disableAllChecks()
    ->disableAutomation();

$command->run();

User fields


Rendering field values

Performed via class Display:

$typeId = 1; // process identifier
$itemId = 1;

$type = Bitrix\Rpa\Driver::getInstance()->getType($typeId);
$userFieldCollection = $type->getUserFieldCollection();
$display = new Bitrix\Rpa\UserField\Display($userFieldCollection);

$item = $type->getItem($itemId);
$controller = new Bitrix\Rpa\Controller\Item();

$data = [];
foreach($userFieldCollection as $userField)
{
    $data[$userField->getName()] = $controller->prepareValue($item->get($userField->getName()));
}

$display->addValues($item->getId(), $data);

$renderedValues = $display->getValues($item->getId());



© «Bitrix24», 2001-2024
Up