Friday, March 12, 2021

#837 - OIC --> Netsuite & HubSpot - User Events calling OIC to sync Price changes

 Following on from the previous post and it's use case - 

Firstly, a BIG THANK YOU to my colleagues Maria and Subhani for their support here!

Back to the pattern - user event script triggered when an Inventory Item is updated.

The updates I'm interested in are those to the buy and sell prices.

This is the buy price - PURCHASE PRICE


This is the sell price - List Price

The HubSpot Product objects has been augmented with a field to hold the Netsuite Inventory Item Internal id. The instructions on doing this have been detailed in a previous post. I also a new custom field to the Netsuite Inventory Item - 


I begin with the following OIC Integration skeleton -

Here is the REST Trigger Request payload - 

My user event leverages javascript. I first need to upload this file to Netsuite - 

I can create a script based on this file, now that it has been uploaded to Netsuite -


I need to apply this script to the following - 

Now to the javascript code - here a big thanks to Maria! The first part checks if the purchase costs has changed. Note the 2 contexts used - oldRecord and newRecord.

It also stores the Netsuite Internal Id and the hubSopt Product id in variables.

I consulted the Netsuite Records Browser to get the actual field names - It is available here

The next part checks for list price changes - 

The final part calls OIC - 

So let's test this out - 

Purchase Price is currently 99.00

List Prices are as follows - I am primarily interested in the USA price of 559.00

Now I change the purchase price to 89.00 and the list price to 449.00.

I save the Inventory Item - 

I check the script log - 

This is a great feature from Netsuite - 

I check the instance in OIC - 

All that's left is to invoke the REST connection to HubSpot in order to update the price(s).

I test out the api call in Postman -

I validate in HubSpot - 

I now replicate in OIC  - 

Activate and test - 

Again, the caveat - the above integration does not include error handling etc.

Next step would be to use the REST adapter to update the relevant Product on HubSpot.

The above script is available for download here

Tuesday, March 9, 2021

#836 - OIC --> HubSpot to Netsuite - Product Sync

Another typical use case between CRM and ERP. The Products listed in CRM must be available in ERP for payments processing, inventory etc. So who should be the master here? I assume ERP.

So Product seeding should be part of the initial HubSpot setup for your company. The basic pattern is as follows - 

Further relevant (e.g. pricing info etc.) Item/Product changes in Netsuite can then be pushed to HubSpot in real-time.

The Logic is simple - read the products from Netsuite, write to HubSpot. Add a custom field/property to the HubSpot Product object to hold the Netsuite Product Id.

If only the real world was so simple - mirroring reality, Netsuite has different types of items - 

Inventory Items - think of physical goods e.g. a bicycle.

Assembly Items - goods made from assembled parts.

Non-Inventory Items - non-physical goods/services - no need for inventory management e.g. a subscription to a cloud service.

I will only consider Inventory Items in this example. Now let's look at the basic Product properties in HubSpot - 



Relatively simple. Now let's look at the HubSpot Product api -

Now, I need to get the internal HubSpot filed names, before trying this out in Postman -

For example the sku field is actually called hs_sku. These internal values can be found here -



Here is the Postman Test and the result in HubSpot -

Ok, so that's HubSpot sorted, now to retrieving the Inventory Items from Netsuite - 

I create a Saved Search in Netsuite to retrieve the salient product information.

This saved Search is then invoked by an OIC integration - again this is a scheduled job which leverages the OIC Netsuite adapter to execute the Saved Search -


Naturally, I will augment this integration, adding a scheduled parameter - dateLastRun. This value will then be used in the Map to GetInventoryItems above - but that's for later. Let's get the basic flow completed.

I create a REST Connection for HubSpot and configure CreateHubSpotProduct as follows - 

Now to the mapping - 

Note the array of name value pairs. I have 6 of these in my Postman request, so I will create 6 pairs.

Now to create the first pair - product name and it's value.

I complete the mappings for the other Product properties.

Then a test - 

I check in HubSpot - 

I check out the iBike - 

All I need to do is add the Netsuite item id to the HubSpot UI - 

Naturally, I can do the same on the Netsuite side - updating a custom field e.g. HubSpotProductId, on the Item object, with the following value -

Now I turn to real-time pricing updates between Netsuite and our CRM app, be that SFDC or HubSpot. The basic pattern is as follows - 

This will be covered in the next post.