I just got access to a trial account of SugarCRM, so no time like the present to try out
an integration use case with Netsuite - syncing SugarCRM Accounts with Netsuite Customers.
I begin by looking at the SugarCRM REST api - this I will be using, courtesy of the OIC REST adapter.
SugarCRM REST API
The REST api base endpoint is mySugarCRMInstance/rest/v10
You should see the following, when you add a /help to that url.
Now what about Authentication?
The screenshot below is one I took from the SugarCRM docs here
Ok I try this out in Postman -
Now I can use this access token in further requests to SugarCRM -
Here I create an Account -
Looks good - and just to prove it - here it is in SugarCRM -
Retrieving an Account is easy - just use the id as key
I can also add a filter to the GET - here I am retrieving Accounts modified after a particular dateTime.
Ok, let's implement this use case in OIC.
Integrating SugarCRM and Netsuite using OIC
I will use the OIC REST adapter to integrate with SugarCRM via its REST API.
The OIC REST adapter makes it very easy to do so, allowing one to configure
the 2 legged OAuth at connection level. This means my integration can concentrate on the
business logic - retrieving modified SugarCRM accounts and syncing them with Netsuite.
Base URL = mySugarCRMInstance/rest/v10
This is what we have already used in Postman.
Now let's go thru these settings one by one -
A great reference here is this excellent blog post from Anuj.
Let's look at setting the Access Token Request field -
What we need here is the curl request minus the curl, so to speak
Starting point again is Postman -
Here is the curl -
I massage this and end up with -
The other settings are mainly default -
Notice the access_token_usage value - this is the Header I use in Postman -
Step 2 - Create a Scheduled Integration
Here is the finished product -
So what's happening here?
This integration runs according to a schedule, e.g. at 5pm every working day.
First action is to GetModifiedAccounts from SugarCRM, leveraging the REST connection I just created. I query for all accounts modified after a particular date - just as I did in the Postman example.
Then I check if the count of modified accounts is greater than 0.
If so, I iterate over the accounts returned - for each account I check whether it already exists in Netsuite. If it doesn't, I create a Netsuite customer for that SugarCRM Account.
A very simple use case - the logic is over-simplified and no error handling has been implemented,
but it will suffice to illustrate how easy it is to do such with OIC.
Step 2.1. Configure a schedule parameter - dateModified
This we will use to query SugarCRM.
Step 2.2. Invoke SugarCRM to get the modified Accounts
Here I leverage the SugarCRM REST Connection, configured as follows -
Request and Response payloads are set to those from my Postman example.
Going back to my test in Postman - the response payload from SugarCRM included
empty arrays e.g.
OIC won't accept this so either remove the element or add some values.
Now to the Mapping -
Step 2.3. I log the number of Accounts returns - default pagination is set to 20.
Step 2.4. I add a SWITCH to branch on count
If count is greater than 0 - I use a FOR EACH action to iterate over each modified account.
Here I just output the Account name
Final Step - Leverage the Netsuite connection to Create CustomerFor in-depth how to implement the GET / Create Netsuite Customer use case,
please refer to the my Netsuite related blog posts here
Here is an extract from the integration, with the Netsuite connectivity -
I check whether the customer exists in Netsuite - using the Netsuite connection - Search - capability
If customer is not found, I use the Netsuite connection to create the customer -
Now to testing the completed integration -
I check in Netsuite for the SugarCRM account, Mississippi Bank Group -