Differences

This shows you the differences between two versions of the page.

Link to this comparison view

en:start:remote_over_http_handler [2016/07/07 15:30] (current)
admin created
Line 1: Line 1:
 +===== Execution: Remote over HTTP Handler =====
  
 +This feature allows you to execute Workflow from any System, which could initiate HTTP Post Requests. You could also submit any values to the workflow and access these variables from every task. \\
 +This allows a very flexible Webservice System you could configure in vtigerCRM Frontend.
 +
 +You could **execute single Workflows by ID** or **trigger a custom trigger**, which could be managed via trigger configuration.
 +
 +<WRAP center info 100%>
 +=== use cases ===
 +  * replacement of Webservice for Record Creation, like Forms on Webpage for Lead collection
 +  * like Forms on Webpage for Lead collection
 +  * execute special processes from webpage (External Administrations) if the record ID of organization is known (generation of quotes, …)
 +</​WRAP>​
 +
 +==== Security & Configuration ====
 +{{ :​ru:​workflow_designer:​config_http_handler.png?​nolink|}}
 +
 +The access to the HTTP Handler is denied per default for all IP's. \\
 +If you want to use such handler, you must grant access for single IP'​s/​IP Ranges to execute a specific trigger/​workflow. \\
 +This configuration could be done in the Workflow Designer configuration on “Settings HTTP Handler”. \\
 +If you press “new permission” or “edit” you will see the following form.
 +{{ :​ru:​workflow_designer:​config_http_handler2.png?​nolink |}}
 +
 +  * The title is only used for usability and don't affect the permission.
 +  * In the IP field you could configure all IP's which get permissions by this entry
 +    * Here you could use single IP's, but also Ranges in the following structure:
 +      * 192.168.0.
 +      * 192.168.0.100-192.168.0.160
 +      * 192.168.0.0/​24
 +  * The Trigger drop down will show all created triggers
 +  * The Workflow drop down will show all workflows together with the ID, which you need for the execution
 +
 +==== Workflow selection ====
 +
 +To configure the Workflow/​Trigger you want to execute, use the following GET Variables:
 +
 +  *** record_id** \\ Which record from CRM should be used by Workflow Designer to append the Workflow \\
 +If you don't want to connect a record, set the record_id = 0
 +  * **workflow_id** \\ Which Workflow should be executed? You get the Workflow ID from the URL in administration
 +
 +<WRAP center info 100%>
 +Examples\\
 +ВYou want to execute a single workflow with no special connected record (You want to create a new lead) use
 +<​Code>?​record_id=0&​workflow_id=<​IDofWorkflow></​Code>​
 +</​WRAP>​
 +
 +==== submit Variables ====
 +
 +To submit variables to the workflow only use POST variables to transfer data. \\
 +The values could be used inside the executed workflows in the **$env** variable.
 +
 +For example if you submit a variable lastname to the workflow, you could access the variable in every task of this workflow by using
 +<​Code>​$env[“lastname”]</​Code>​.
 +
 +=== PHP Example ===
 +
 +<​Code>​
 +$url = '<​urlofvtigerCRM>/<​shorturl>?<​ExecutionConfiguration>';​
 + 
 +$fields = array(
 +   '​firstname'​ => "​Firstname",​
 +   '​lastname'​ => "​Lastname",​
 +   '​street'​ => "​streetname 123"
 +);
 + 
 +foreach($fields as $key=>​$value) {
 +  $fields_string .= $key.'​='​.urlencode($value).'&';​
 +}
 +rtrim($fields_string,​ '&'​);​
 + 
 +$ch = curl_init();​
 + 
 +curl_setopt($ch,​CURLOPT_URL,​ $url);
 +curl_setopt($ch,​CURLOPT_POST,​ count($fields));​
 +curl_setopt($ch,​CURLOPT_POSTFIELDS,​ $fields_string);​
 +curl_setopt($ch,​CURLOPT_RETURNTRANSFER,​true);​
 +$result = curl_exec($ch);​
 +curl_close($ch);​
 +</​Code>​
 +
 +You want to execute the workflow with the **ID 77** on the **record 852** you need to write:
 +
 +<​Code>​
 +$url = '<​urlofvtigerCRM>/<​shorturl>?​record_id=852&​workflow_id=77';​
 + 
 +$fields = array(
 +   '​firstname'​ => "​Firstname",​
 +   '​lastname'​ => "​Lastname",​
 +   '​street'​ => "​streetname 123"
 +);
 + 
 +foreach($fields as $key=>​$value) {
 +  $fields_string .= $key.'​='​.urlencode($value).'&';​
 +}
 +rtrim($fields_string,​ '&'​);​
 + 
 +$ch = curl_init();​
 + 
 +curl_setopt($ch,​CURLOPT_URL,​ $url);
 +curl_setopt($ch,​CURLOPT_POST,​ count($fields));​
 +curl_setopt($ch,​CURLOPT_POSTFIELDS,​ $fields_string);​
 +curl_setopt($ch,​CURLOPT_RETURNTRANSFER,​true);​
 +$result = curl_exec($ch);​
 +curl_close($ch);​
 +</​Code>​