I am trying to develop a workflow in Processmaker 4 community that require some scripted tasks to be executed but I am facing in issues in things that should be simple such as:
- How to debug the code in Processmaker scripts. Is there access to stdout and sterr somehow?
- How to access request variables form the PHP script.
- How to access the files that have been uploaded to a process from the PHP script.
Does anyone know of a good resource explaining in detail how to create PHP scripts in Processmaker?
So far I have found the following documentation https://github.com/ProcessMaker/docker-executor-php/tree/develop/docs/sdk which certainly seems to open the door on how to access files and Processmaker information but I am still struggling trying to find a way to properly debug fairly complex scripts.
You can debug your script using the Script Editor (at /designer/scripts edit your script) by inserting echo statements at within the code. These statements will be displayed in the "Output" panel, helping you track the script's progress and identify any issues. Additionally, you can access request variables using the
$data
variable. For testing purposes, you can enter sample values in the "Sample Input" panel and observe how the script handles them.Please consider that writing to STDOUT in a script task will result in a runtime exception, since it is not permitted. The use of STDOUT is intended solely for debugging purposes. Exercise caution while employing it to avoid unexpected errors during script execution.
The following is an simple example:
For this Sample Input:
Will return the following output: