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

Moderator: amosbatto

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 387 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 amosbatto
#822870
If you want to add a new trigger functions, then you create a plugin with the PMFunctions Class.

Then you need to add comments in this file of your new plugin:
pluginName/classes/class.pmFunctions.php.

You can study the source code in my extraFunctions plugin for an example:
https://www.pmusers.com/index.php/ExtraFunctions_plugin
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 311 times
ice_screenshot_20190221-145244.png
ice_screenshot_20190221-145244.png (19.81 KiB) Viewed 311 times
ice_screenshot_20190221-143000.png
ice_screenshot_20190221-143000.png (99.87 KiB) Viewed 311 times
User avatar
By amosbatto
#823038
Can you export your plugin and post the .tar file here (or post your pluginName/classes/class.pmFunctions.php file)?

Also, what version of Processmaker?, manual or bitnami install? What operating system?
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 298 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 278 times
ice_screenshot_20190221-143000.png
ice_screenshot_20190221-143000.png (99.87 KiB) Viewed 278 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);

Learn how to increase the max upload size setting […]

To fix this, you will have to edit the code for[…]

Using RTL.CSS in dynaforms

I reinstalled the processmaker and used the po fil[…]

Hi Member's I am trying to create a Dashboard of […]