Documentation

GetDocumentStates

array
public static function CBPDocument::GetDocumentStates(  array documentType,
 array documentId = null
);

This method returns an array of all workflows and their statuses for this document. If document code is specified, then method returns an array of all workflows launched for this document (including the completed workflows), as well as workflow templates, configured to autorun when document is modified.

Note: Method receives an array of configuration parameters and generates scripts, required to show file dialog. Static method.

Method parameters

ParameterDescription
documentTypeDocument type as an array(module, document_class, document_type_code_in_module)
documentIdDocument code as an array(module, document_class, document_code_in_module). If the document is new, then null

Returned value

Array consists of the following:

array(
workflow_or_template_code => array(
"ID" => workflow_code,
"TEMPLATE_ID" => workflow_template_code,
"TEMPLATE_NAME" => workflow_template_name,
"TEMPLATE_DESCRIPTION" => workflow_template_dscription,
"TEMPLATE_PARAMETERS" => parameter_array_of_workflow_template_launch,
"STATE_NAME" => workflow_current_status,
"STATE_TITLE" => current_workflow_status_name,
"STATE_MODIFIED" => workflow_status_modified_date,
"STATE_PARAMETERS" => events_array_received_by_workflow_in_this_status,
"STATE_PERMISSIONS" => operation_permissions_for_the_document_in_this_status,
"WORKFLOW_STATUS" => workflow_status,
),
. . .
)
Depending on the fact, whether it is a workflow or a template, portion of fields may not be specified. Status for finite state machine-type workflow template is the initial status of this workflow type template.
Array of parameters to launch a workflow template (TEMPLATE_PARAMETERS) is presented as follows:
array(
"param1" => array(
"Name" => "Parameter 1",
"Description" => "",
"Type" => "int",
"Required" => true,
"Multiple" => false,
"Default" => 8,
"Options" => null,
),
"param2" => array(
"Name" => "Parameter 2",
"Description" => "",
"Type" => "select",
"Required" => false,
"Multiple" => true,
"Default" => "v2",
"Options" => array(
"v1" => "V 1",
"v2" => "V 2",
"v3" => "V 3",
. . .
),
),
. . .
)
Available type of parameters: int, double, string, text, select, bool, date, datetime, user.
Array of events, received by the workflow in this status (STATE_PARAMETERS) is presented as follows:
array(
array(
"NAME" => received_event,
"TITLE" => received_event_name,
"PERMISSION" => array_of_user_groups_that_can_send_an_event
),
. . .
)
Permission rights to perform operations with a document in this status (STATE_PERMISSIONS) are as follows:
array(
operation => array_of_user_groups_that_can_perform_operation,
. . .
)

Examples

<?
$documentType = array("bizproc", "CBPVirtualDocument", "type_".$blockId);
$documentId = array("bizproc", "CBPVirtualDocument", $id); $arDocumentStates = CBPDocument::GetDocumentStates($documentType, $documentId); foreach ($arDocumentStates as $arDocumentState)
{
   $arDocumentStateTasks = CBPDocument::GetUserTasksForWorkflow($GLOBALS["USER"]->GetID(), $arDocumentState["ID"]);
   print_r($arDocumentStateTasks);
}
?>


© «Bitrix24», 2001-2024
Up