TOPIC:

Post data to Dolibarr CRM 1 week 5 days ago #261449

  • Topic Author
  • unratgeber
  • Offline
  • Fresh Breezer
  • Fresh Breezer
  • Posts: 12
  • Thanks: 0
Hello everybody,

I want to collect data with a Breezing Forms form in a Joomla Website and post the data to Dolibarr CRM and get records created there.

I have created a test php file which is working:
<?php
$httpheader = ['DOLAPIKEY: 123456789XYZ'];
$url = "https://URL.net/htdocs/api/index.php/thirdparties";

$data = array();
$data["name"]="TEST COMPANY";

$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
curl_setopt($curl, CURLOPT_HTTPHEADER, $httpheader);

$result = curl_exec($curl);
curl_close($curl);

echo$result;
?>

Info for the API in Dolibarr can be found here: wiki.dolibarr.org/index.php?title=Module...r)#Examples_with_PHP

For the integration in Breezing Forms I have found that article: crosstec.org/de/support/online-dokumenta...re-url-schicken.html

But I don't know how to "translate" the php code above into Breezing Forms code.

I have tried to put
$data["name"]="'.htmlentities( ff_getSubmit ('Company') ).'";
into the above php code but in Dolibarr it only creates a company with '.htmlentities( ff_getSubmit ('Company') ).' in the company name field.

Does someone know what to put into Breezing Forms end submit section?

Thank you very much.

Please Log in or Create an account to join the conversation.

Post data to Dolibarr CRM 1 week 5 days ago #261450

  • Mirec's Avatar
  • Mirec
  • Offline
  • Gold Breezer
  • Gold Breezer
  • Posts: 454
  • Karma: 2
  • Thanks: 19
Hi,


if I understood well, you can send data to another URL using this code in End submit pieces:
echo '<form action="url Adress" method="post" name="myForm">
<input type="hidden" name="field1" value="'.htmlentities( ff_getSubmit('field1') ).'"/>
<input type="hidden" name="field2" value="'.htmlentities( ff_getSubmit('field2') ).'"/>
<!-- more fields ... -->
</form>
<script>document.myForm.submit();</script>
';
exit;

Instead myForm, please insert the name of your Form (Not title).
Instead, Field1 and Field2 insert the name of your field (Not title).

If you need more help, feel free to ask!
Regards,
Mirko

Please Log in or Create an account to join the conversation.

Post data to Dolibarr CRM 1 week 5 days ago #261451

  • Topic Author
  • unratgeber
  • Offline
  • Fresh Breezer
  • Fresh Breezer
  • Posts: 12
  • Thanks: 0
Hello Mirko,

thank you for your reply.

I did what you write, but it doesn't put into Dolibarr the value that was entered into the form. It puts "'.htmlentities( ff_getSubmit ('Company') ).'" into the company field name (in Dolibarr).

So I need the expression in Breezing Forms syntax that will do the same like the php code (see my 1st post) and that puts the value of the field "name" into Dolibarr. The php code works.

Kind regards

Please Log in or Create an account to join the conversation.

Post data to Dolibarr CRM 1 week 5 days ago #261452

  • Mirec's Avatar
  • Mirec
  • Offline
  • Gold Breezer
  • Gold Breezer
  • Posts: 454
  • Karma: 2
  • Thanks: 19
Hi,

I will investigate it, and let you know the result

Regards,
Mirko

Please Log in or Create an account to join the conversation.

Post data to Dolibarr CRM 1 week 5 days ago #261453

  • Topic Author
  • unratgeber
  • Offline
  • Fresh Breezer
  • Fresh Breezer
  • Posts: 12
  • Thanks: 0
thank you, Mirko. I appreciate your work!

BTW: anyone searching for a very good CRM system: have a look at Dolibarr. This is really a great piece of software.

Please Log in or Create an account to join the conversation.

Post data to Dolibarr CRM 1 week 4 days ago #261490

  • Mirec's Avatar
  • Mirec
  • Offline
  • Gold Breezer
  • Gold Breezer
  • Posts: 454
  • Karma: 2
  • Thanks: 19
Hi,

here below is described how to send the form data to some API

I would suggest using an end submit a piece (=PHP) and forward the desired data using curl, performing the API call (usually a post).

Here a general example addressing an imaginary rest service.
It assumes the data needs to be sent to the rest API service JSON encoded.
It will depend on the actual API you are targeting if you actually need this or not, but this is a common procedure:
// loading the BreezingForms API, mostly for using ff_getSubmit
$this->execPieceByName('ff_InitLib');

/**
   This is an example cURL rest API call from:
   https://tutorialsclass.com/php-rest-api-post-data-using-curl/
*/

// User data to send using HTTP POST method in curl

// data taken from the form:

$data = array('name'=>ff_getSubmit("name"),'salary'=>ff_getSubmit("salary"), 'age' => ff_getSubmit("age"));

// Data should be passed as json format
$data_json = json_encode($data);

// API URL to send data
$url = 'http://dummy.restapiexample.com/api/v1/create';

// curl initiate
$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, $url);

curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));

// SET Method as a POST
curl_setopt($ch, CURLOPT_POST, 1);

// Pass user data in POST command
curl_setopt($ch, CURLOPT_POSTFIELDS,$data_json);

curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);

// Execute curl and assign returned data
$response  = curl_exec($ch);

// Close curl
curl_close($ch);

// See response if data is posted successfully or any error
// for debugging remove the comments
//print_r ($response);
//exit;

This could need to be adjusted, matching your form elements. Basically changing the field names (not titles) in ff_getSubmit() calls and likely adding a few more, depending on what you need to send.

In the end, the code would need to go into form => advanced => more options => submit pieces => end submit => click "custom".

Please let me know if this is what you are looking for.

Regards,
Mirko
The following user(s) said Thank You: unratgeber

Please Log in or Create an account to join the conversation.

Moderators: ForumSupport
Time to create page: 0.052 seconds

BreezingForms Pro 1.4.7 for WordPress Released!

Available in the membership section.

September Discount!

Massive discounts on all subscriptions!

Get Your Subscription Here

Quick Links

Downloads

BreezingForms

ContentBuilder

BreezingCommerce

Templates

Documentation

BreezingForms

ContentBuilder

BreezingCommerce

Apprendre BreezingForms (French Community)

Apprendre et maîtriser BreezingForms par des tutoriels et exemples, le tout en français

breezingforms.eddy-vh.com

Questions et réponses sur les forums de l'AFUJ

AFUJ

Special Offer

Summer Sale! All subscriptions at a special price!

Includes prio support, all of our current and future Joomla!® extensions and Joomla!® templates for the duration of your membership.

Get it from here

3rd Party Discount - 25% Off

We help you to keep your costs under control. If you are a new member and purchased a form building tool from a different form vendor, then you'll get a 25% discount on our subscription plans.

How to receive the discount:

Send us a quick email to sales@crosstec.org with a proof of purchase (for example a paypal receipt), await payment instructions and enjoy your membership!