Skip to main content

11.3 SDK Task Condition

It is a type of function that is used to perform custom checks in process control tasks (conditional tasks).

To register them, use the method:

SDK::setProcessMakerTaskCondition($func, $src, $label)
$func : name of the function
$src : path to the file containing the function
$label : label of the function

To unregister the file, use:

SDK::unsetProcessMakerTaskCondition($func);
$func : name of the function

If you call on the “initial condition” task (task in which the process start rules are defined), it is possible to make the start of the process specific based on the returned result.


taskCondition_1.png

If you call instead simple control tasks they allow you to make the process take different paths based on the returned result.

taskCondition_2.png

Functions of this type will always be available in the form of variables that can be used to perform checks.
A concrete example of an SDK function of this type is the “get_running_process_current_user” function that allows you to check whether the name of the current user is the same or different from the user defined in the condition.
If used in the initial condition, it allows you to start the process only if the current user is the same as a specific user.


taskCondition_3.PNG

Example

I register a function to check if the company's billing address is the same as the shipping address.

SDK::setProcessMakerTaskCondition('vte_compare_account_bill_ship_street', 'modules/SDK/src/ProcessMaker/Utils.php', 'Indirizzi di spedizione e fatturazione uguali [e/n]');

The implemented function contains the following parameters.
$module: module of the entity on which the condition is executed
$id: identifier of the entity in ws format (e.g. 3x55126)
$data: array with the values ​​of the fields of the record

The function must return a string to be used for the interface-side comparison.

function vte_compare_account_bill_ship_street($module, $id, $data) {
	list($wsModId,$id) = explode('x',$id);	// do it every time
	
	if ($data['bill_street'] == $data['ship_street']) {
		return 'e';
	} else {
		return 'n';
	}
}

At this point I can set up a process that starts when a company is created when the billing address is different from the shipping address.

Schermata 2024-02-23 alle 13.02.56.png