Questions and discussion about developing processes and programming in PHP, JavaScript, web services & REST API.
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
#822852
How to create new custom trigger with code in rest api?
Attachments
ice_screenshot_20190211-134654.png
ice_screenshot_20190211-134654.png (25.12 KiB) Viewed 5846 times
User avatar
By ziadeh
#822856
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
#823025
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?
Attachments
ice_screenshot_20190221-143151.png
ice_screenshot_20190221-143151.png (21.24 KiB) Viewed 5770 times
ice_screenshot_20190221-145244.png
ice_screenshot_20190221-145244.png (19.81 KiB) Viewed 5770 times
ice_screenshot_20190221-143000.png
ice_screenshot_20190221-143000.png (99.87 KiB) Viewed 5770 times
User avatar
By dhanaulia
#823045
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)
Attachments
ice_screenshot_20190222-102423.png
ice_screenshot_20190222-102423.png (35 KiB) Viewed 5757 times
User avatar
By dhanaulia
#823070
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?
Attachments
ice_screenshot_20190221-143151.png
ice_screenshot_20190221-143151.png (21.24 KiB) Viewed 5737 times
ice_screenshot_20190221-143000.png
ice_screenshot_20190221-143000.png (99.87 KiB) Viewed 5737 times
User avatar
By amosbatto
#823101
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);

A 1xbet clone script is a pre-designed software so[…]

4rabet clone script is enabling entrepreneurs to e[…]

Parimatch clone script is enabling entrepreneurs t[…]

In the world of cryptocurrency, a wallet is an app[…]