Views: 10686
Last Modified: 16.09.2014

An activity may have properties which values are set up when adding activities to a business process template. Both constants and links to properties of other activities of a business process may constitute property values.

Activity properties are described in the activity class designer by defining an array in the arProperties class members:

public function __construct($name)
{
	parent::__construct($name);
	$this->arProperties = array("Title" => "", "MyProperty" => "");
}

The names of the properties constitute the keys in the property definition array and default values of the properties constitute the values.

When executing an activity, the properties are available as class members:

$this->MyProperty

Input parameters (properties) of a business process are available as properties of a root activity of the business process. Any activity of a business process may access input parameters of a business process.

For example, if a business process was launched using the code:

// Business process template code
$workflowTemplateId = 12;

// Business process is launched for the document which is an infoblock element with code 358
$documentId  = array("iblock", "CIBlockDocument", 358);

// Input parameters of the business process
$arParameters = array("MyProperty" => "red");

$runtime = CBPRuntime::GetRuntime();
$wi = $runtime->CreateWorkflow($workflowTemplateId, $documentId, $arParameters);
$wi->Start();

then in any activity of this business process a parameter value can be obtained using the following code:

$rootActivity = $this->GetRootActivity();
if ($rootActivity->IsPropertyExists("MyProperty"))
	$val = $rootActivity->MyProperty;
//  $val == "red"

Developer describes activity properties when writing activity code. Income parameters of a business process (a.k.a. properties of root activity of a business process) are described by users when creating a business process template.

Both constants and links to properties of other business process activities may constitute property values, provided that these activities were executed previously.

In order to make sure that at the time of a business process execution the property value of one activity is the property value of another activity executed above, the following array must be set as a property value of the first activity at the stage of creating the template for such business process:

array("name of the activity which properties are referred to", "property name")

In case of simple types of these properties, the following string must be set as a property value of the first activity:

"{=activity_name, property_name}"

In order to refer to an input parameter (property) of a business process which is available as a property of a root activity of a business process, the word Template should be used as the name of the activity:

array("Template", "property name") "{=Template, property_name}"

In general terms, the following words can be used as an activity name:

  • Document – to access an arbitrary field of the document for which a business process is started;
  • Template – to access an input parameter (property) of a business process (root activity);
  • Variable – to access a business process variable;
  • User – to obtain the code of the current user ("ID" must be indicated as the property name);
  • System – accessing system variables, presently only the property Now (current date in the website format) is available;
  • Any other name – to access an action property with this name.

For example, if during development the following string is set as a property value:

"Document [url={=Template:PathTemplate}]{=Document:NAME}[/url] was approved"

and the workflow is launched with the input parameter PathTemplate equal to file.php for the document named Chart of Accounts, the following string will constitute the property value during activity execution:

"Document [url=file.php]Chart of Accounts[/url] was approved"




Courses developed by Bitrix24