Questions and discussion about developing processes and programming in PHP, JavaScript, web services & REST API.

Moderators: ArturoRobles, ArturoRobles

Forum rules: Please search to see if a question has already asked before creating a new topic. Please don't post the same question in multiple forums.
User avatar
By dhanaulia
How to create new custom trigger with code in rest api?
ice_screenshot_20190211-134654.png (25.12 KiB) Viewed 1479 times
User avatar
By ziadeh
You can create a trigger in PM designer and call it from rest api read this

Also if you want to create a custom code and call it from rest api, you have to create a php file in
Code: Select all
{Your processmaker path}/workflow/engine/src/ProcessMaker/Services/Api
There are couple of test files so you can get some ideas from them.

After you create a rest api php file and made your custom code you need to delete routes.php file:
Code: Select all
{Your processmaker path}/shared/sites/workflow/routes.php
And PM will generate a new one that have your code.

Also you can use Extrarest api for Amosbatto
User avatar
By dhanaulia
i create new trigger with code using postman. it was success, but when i open in website, code is gone and type change to wizard. can anyone help me?
ice_screenshot_20190221-143151.png (21.24 KiB) Viewed 1403 times
ice_screenshot_20190221-145244.png (19.81 KiB) Viewed 1403 times
ice_screenshot_20190221-143000.png (99.87 KiB) Viewed 1403 times
User avatar
By dhanaulia
I didn't have a code plugin. Is really necessary to create php file? but i just trying to create new trigger with code. because i trying in website and completely fine. i just copy my code in web and paste in postman. but the result was different (i try in postman, and type change to wizard)
ice_screenshot_20190222-102423.png (35 KiB) Viewed 1390 times
User avatar
By dhanaulia
i followed your instructions and response was 200 but i open that trigger in website, trigger type turns become wizard (it happened if i add some tri_webbot). but if i create new trigger without add code in tri_webbot, when i open my trigger in website its normal. how can i adding some code in tri_webbot without error like that?
ice_screenshot_20190221-143151.png (21.24 KiB) Viewed 1370 times
ice_screenshot_20190221-143000.png (99.87 KiB) Viewed 1370 times
User avatar
By amosbatto
I got it to work by setting tri_param to "" (an empty string).

Here is the PHP code I used:
Code: Select all
	$processId = '2606490355c64d95da1c7d2093841486';
	$aVars = array(
	    "tri_title"      => "Set products list 2",
		"tri_description"=> "short list of products 2",
		"tri_type"       => "SCRIPT",
		"tri_webbot"     => "@=aProducts = array(
	array('hello', 'Hello'),
	array('kitty', 'Kitty')
@@test = 2;",
		"tri_param"      => ""

	$url = "/api/1.0/workflow/project/$processId/trigger";
	$oRet = pmRestRequest("POST", $url, $aVars, $oToken->access_token);
CRUD and Process

Liliana i want to hear your answer if i say "[…]

Enabling SQL Server in Windows

I’m excited to uncover this page. I need to […]

Hi, Please use query like this: SELECT Forneced.[…]

Casos estão carregando em branco

Boa tarde! Prezados, estou com problemas em algun[…]