<p>I was able to accomplish this by grabbing <a href="https://github.com/lindseydiloreto/craft-businesslogic" rel="nofollow noreferrer">Craft Business Logic</a>, stripping out most of the examples, and simply listening for a form submission:</p>

<pre><code>craft()-&gt;on('sproutForms.onSaveEntry', function (Event $event)
{
    $entry = $event-&gt;params['entry'];
    $content = $entry-&gt;getContent()-&gt;getAttributes();

    // Let's not pass fields we don't need
    $fields = array();
    $ignore = array('id', 'slug', 'title', 'handle', 'locale', 'element', 'elementId');

    foreach ($content as $field =&gt; $value)
    {
        if(!in_array($field, $ignore))
        {
            $fields[$field] = $value;
        }
    }

    $fields = http_build_query($fields);
    $ch = curl_init('https://url-to-sugar.crm/index.php?entryPoint=WebToLeadCapture');
    curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);

    $response = curl_exec($ch);
    curl_close($ch);
}
</code></pre>

<p>I just created an init function <a href="https://github.com/lindseydiloreto/craft-businesslogic/blob/master/businesslogic/BusinessLogicPlugin.php#L6" rel="nofollow noreferrer">in the plugin</a> and added this there. I didn't need to use an API because the data is only flowing in one direction. I just used curl to push the data.</p>

CC BY-SA 3.0
2018-03-23T22:05:27.390Z
2018-03-23T22:13:25.683Z
2018-03-23T22:13:25.683Z
3x5
<p>At the time of this posting, I don't know of any out of the box SugarCRM integration with Craft.</p>

<p>While Craft is quite capable of integrating with almost anything, the intro section in their docs also states that it's a CMS for people who build custom websites. There are millions of potential products with REST APIs and millions of different needs in how companies need to interface with those APIs. Any specific integration will likely require some additional effort to make happen. Craft's ability to integrate with anything comes via the power and flexibility they give developers to extend the CMS for custom scenarios.</p>

<p>Sprout Forms also provides several ways that it can be adapted to custom scenarios and extended to interface with other services. Each service is different and I am not familiar with SugarCRM so your mileage may vary, but here are some of the tools Sprout Forms makes available to you to customize how Forms are submitted:</p>

<ul>
<li><a href="https://sprout.barrelstrengthdesign.com/craft-plugins/forms/docs/customization/template-overrides" rel="nofollow noreferrer">Template Overrides</a> allow you to customize how your base Sprout Forms templates are formatted. In the case the endpoint you are submitting to has a particular format that fields names need to comply with, you can adjust that here.</li>
<li><a href="https://sprout.barrelstrengthdesign.com/craft-plugins/forms/docs/customization/payload-forwarding" rel="nofollow noreferrer">Payload Forwarding</a> allows you to submit your form to a third-party URL instead of to Craft. In the settings area you can choose whether your data is saved to Craft or whether you want to trigger emails from Craft or if you just want to offload everything and send your form submission to a third party.</li>
<li><a href="https://sprout.barrelstrengthdesign.com/craft-plugins/fields/docs/overview/hidden-field" rel="nofollow noreferrer">Sprout Fields</a> integrates with Sprout Forms and provides a Hidden and Invisible Field if you want to include things like API Keys in your request but not have them presented to the user in the form.</li>
</ul>

<p>While a lot can be done with the above integration options, each situation is different and we've also run into scenarios where we needed to create a small plugin to help handle and hand off the data between Sprout Forms and another system. We have plans to improve the flexibility of these types of integrations even more as we get upgraded to Craft 3. </p>

<p>Unless there is a large need for a specific integration (like SugarCRM), it's likely that you won't find a specific plugin addressing the issue and that you'll be at some level custom development territory. If you do see integrations for specific platforms, it's also worth asking: how likely is it that the developer who created this plugin has enough clients using it that they will actually update the plugin in the future?</p>

<p>In my experience, specific integrations often require project-specific budgets and are best handled in direct client relationships and it's important to communicate with clients and help them understand that these types of integrations may also require additional maintenance and update costs down the road that are specific to their needs.</p>

<p>We often help clients with small projects where someone needs to extend Craft or a plugin to integrate with a new third-party system and while our plugins support some integrations publicly, they support a lot more integrations privately as those private integrations often solve a specific client's needs and we need to be clear with those client's using them that they will only receive updates if someone can cover the development costs to maintain them.</p>

CC BY-SA 3.0
2018-02-19T21:50:00.283Z
Thanks, I am getting somewhere but I want to be able to push data to both Craft and offsite, if possible. You mentioned that if the endpoint required a field format, I can adjust it with templates. However, I noticed that when I set my field names, e.g. 'first_name', the actual name it gets is 'fields[first_name]'. If I use an override to take out the fields[] part, the form no longer submits to the cms.
3x5
CC BY-SA 3.0
2018-02-20T23:17:02.087Z
Sometimes different data formats are needed to submit data to multiple systems and, right now, Sprout Forms can only send that data in a single format. We'll be reviewing this once we get upgraded to Craft 3. For now, you could keep the Craft-friendly format with your form submission and submit the data to a custom plugin endpoint that modifies and forwards the data to your other endpoint. Right now this situation will likely require the help of another custom helper plugin to modify or remap the data at the right time.
Ben Parizek
CC BY-SA 3.0
2018-02-14T14:26:50.547Z
2018-02-14T14:26:50.547Z
Ben Parizek
<p>SugarCRM has a REST API, and Craft boasts its ability to integrate with almost anything that has an API; however, I am working on a site that uses Sprout Forms, which doesn't mention anything in their docs about integration.</p>

<p>Is there a way, in addition to emails and saved entries, for Craft to push Sprout Form data to SugarCRM?</p>

<p>If this isn't possible, if there another contact form solution that will integrate this way?</p>

<plugin-sproutforms><integration>
How do I push contact form data to SugarCRM? (currently using Sprout Forms)
# How do I push contact form data to SugarCRM? (currently using Sprout Forms)

(Asked by: username_0 on 2018-02-13)

SugarCRM has a REST API, and Craft boasts its ability to integrate with almost anything that has an API; however, I am working on a site that uses Sprout Forms, which doesn't mention anything in their docs about integration.

Is there a way, in addition to emails and saved entries, for Craft to push Sprout Form data to SugarCRM?

If this isn't possible, if there another contact form solution that will integrate this way?

**Tags:** plugin-sproutforms, integration

---

## 2 answers

### Answer by username_0 on 2018-03-23. Score: 2

I was able to accomplish this by grabbing Craft Business Logic, stripping out most of the examples, and simply listening for a form submission:
craft()->on('sproutForms.onSaveEntry', function (Event $event)
{
    $entry = $event->params['entry'];
    $content = $entry->getContent()->getAttributes();

    // Let's not pass fields we don't need
    $fields = array();
    $ignore = array('id', 'slug', 'title', 'handle', 'locale', 'element', 'elementId');

    foreach ($content as $field => $value)
    {
        if(!in_array($field, $ignore))
        {
            $fields[$field] = $value;
        }
    }

    $fields = http_build_query($fields);
    $ch = curl_init('https://url-to-sugar.crm/index.php?entryPoint=WebToLeadCapture');
    curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);

    $response = curl_exec($ch);
    curl_close($ch);
}

I just created an init function in the plugin and added this there. I didn't need to use an API because the data is only flowing in one direction. I just used curl to push the data.


---

### Answer by username_1 on 2018-02-14. Score: 1

At the time of this posting, I don't know of any out of the box SugarCRM integration with Craft.

While Craft is quite capable of integrating with almost anything, the intro section in their docs also states that it's a CMS for people who build custom websites. There are millions of potential products with REST APIs and millions of different needs in how companies need to interface with those APIs. Any specific integration will likely require some additional effort to make happen. Craft's ability to integrate with anything comes via the power and flexibility they give developers to extend the CMS for custom scenarios.

Sprout Forms also provides several ways that it can be adapted to custom scenarios and extended to interface with other services. Each service is different and I am not familiar with SugarCRM so your mileage may vary, but here are some of the tools Sprout Forms makes available to you to customize how Forms are submitted:

* [Template Overrides](https://sprout.barrelstrengthdesign.com/craft-plugins/forms/docs/customization/template-overrides) allow you to customize how your base Sprout Forms templates are formatted. In the case the endpoint you are submitting to has a particular format that fields names need to comply with, you can adjust that here.
* [Payload Forwarding](https://sprout.barrelstrengthdesign.com/craft-plugins/forms/docs/customization/payload-forwarding) allows you to submit your form to a third-party URL instead of to Craft. In the settings area you can choose whether your data is saved to Craft or whether you want to trigger emails from Craft or if you just want to offload everything and send your form submission to a third party.
* [Sprout Fields](https://sprout.barrelstrengthdesign.com/craft-plugins/fields/docs/overview/hidden-field) integrates with Sprout Forms and provides a Hidden and Invisible Field if you want to include things like API Keys in your request but not have them presented to the user in the form.

While a lot can be done with the above integration options, each situation is different and we've also run into scenarios where we needed to create a small plugin to help handle and hand off the data between Sprout Forms and another system. We have plans to improve the flexibility of these types of integrations even more as we get upgraded to Craft 3.

Unless there is a large need for a specific integration (like SugarCRM), it's likely that you won't find a specific plugin addressing the issue and that you'll be at some level custom development territory. If you do see integrations for specific platforms, it's also worth asking: how likely is it that the developer who created this plugin has enough clients using it that they will actually update the plugin in the future?

In my experience, specific integrations often require project-specific budgets and are best handled in direct client relationships and it's important to communicate with clients and help them understand that these types of integrations may also require additional maintenance and update costs down the road that are specific to their needs.

We often help clients with small projects where someone needs to extend Craft or a plugin to integrate with a new third-party system and while our plugins support some integrations publicly, they support a lot more integrations privately as those private integrations often solve a specific client's needs and we need to be clear with those client's using them that they will only receive updates if someone can cover the development costs to maintain them.

> **Comments:**
> **username_0**: Thanks, I am getting somewhere but I want to be able to push data to both Craft and offsite, if possible. You mentioned that if the endpoint required a field format, I can adjust it with templates. However, I noticed that when I set my field names, e.g. 'first_name', the actual name it gets is 'fields[first_name]'. If I use an override to take out the fields[] part, the form no longer submits to the cms.  
> **username_1**: Sometimes different data formats are needed to submit data to multiple systems and, right now, Sprout Forms can only send that data in a single format. We'll be reviewing this once we get upgraded to Craft 3. For now, you could keep the Craft-friendly format with your form submission and submit the data to a custom plugin endpoint that modifies and forwards the data to your other endpoint. Right now this situation will likely require the help of another custom helper plugin to modify or remap the data at the right time.  

---

