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
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 -
I check the script log -
Next step would be to use the REST adapter to update the relevant Product on HubSpot.
The above script is available for download here
No comments:
Post a Comment