IS THERE ANYTHING LIKE WEBHOOK IN NETSUITE?! AND H...
# general
m
IS THERE ANYTHING LIKE WEBHOOK IN NETSUITE?! AND HOW DOES ONE BUILD IT?!
s
You build it using mixed case, not all upper case.
🤣 8
joking aside, a suitelet could be crafted to act as a webhook
s
If you are trying to receive a webhook in Netsuite, you would setup a RESTlet and then send your webhook to the RESTlet url. If you want to send a webhook from Netsuite, then you would need to use the HTTPS module in SuiteScript. You can use the HTTPS module on both server and client scripts.
s
RESTlets require authentication that most 'webhooks' can't handle.
b
you are very lucky if you can get away with using suitelets as a webhook
webhooks are usually done as a POST, and suitelets require a browser looking user agent for POSTs
most webhook type integrations dont allow you to control the user agent header
m
My use case specifically was to have Netsuite POST messages to an app I've been building. Most of what I find is about putting stuff into Netsuite. I tried using some Suitescript on a workflow before but it didn't work. I'm not sure if something was written or configured wrong. I'd be happy to review some guides if anyone has them. @thread
b
if its the other direction and you are sending data to a webhok, you have better choices
usually involves writing a script that uses https.post
m
What I have right now is a realtime Elixir application that receive and deal with POST messages easily. I have about 8 SaaS softwares connected to it. With regards to Netsuite, it's primary use right now is to synchronize the status of a Job in Netsuite to a Deal in Hubspot. Right now my application mirrors the entire Netsuite database into itself via Netsuite's REST API. With the way that is working, I'm not liking having to poll Netsuite for information. I'd rather be able to handle live updates rather than evaluating the whole poll result within my application.
s
In case you are looking for a solution that does not require SuiteScript, you might consider using Zapier to "Trigger" when a record is added to a saved search or when a record is submitted. Then you could have the next step in the "Zap" send the data to your webhook url. We use this product to connect Zapier with Netsuite. https://in8sync.com/zapier-netsuite-integration/
m
God that is expensive... But this is the most practical way to get live events out of Netsuite? @Shane Brown
s
I don't know that it's the most practical way, but I do believe this is the cheapest option that does not involve SuiteScript. There are many integration platforms that can get data from Netsuite, but most of them are very expensive (Boomi, Celigo, Jitterbit, Workato, etc.) When you look at the subscription cost for Zapier plus that in8sync connector, it ends up being much cheaper. Currently the in8sync connector has a trigger for "When a new record is created/updated", "When a new record is added to a saved search". You can optionally include "Date Last Modified" in the search results to also trigger when a record on the search is modified.
We are currently using both Zapier and Celigo's integrator.io product. We use Zapier for small workflows (like sending webhooks) but use integrator.io for moving lots of data at once (ecommerce orders, inventory, product data, etc.)
s
I'm curious how they implement
when a new recordi is added to a saved search
s
I believe they hit a RESTlet every 5 mins. The RESTlet contains the logic but it is a locked bundle so I can't see the details.
🤔 1
👀 1
m
They'd need a mad tier with Netsuite API right? Or are they using SOAP
s
They are not using SOAP. We currently have 1 Netsuite Cloud Plus license and it's been sufficient. I think this will largely depend on how often you are checking Netsuite.
b
my favored joke solution would be to implment integration be email update alerts
that said, there are 2 general classes of solutions if you want to implement it yourself in suitescript
the first is user event script, which will trigger whenever an event like a record edit is triggered
s
The APM tool in Netsuite is very helpful for determining if there will be issues with concurrency/request limits
👀 1
b
the second is a scheduled solution like map/reduce scripts or actual scheduled scripts
the scheduled ones usually involve logic based off the last modified date
m
@battk I'm down to implement in SuiteScript. Given what @Shane Brown had mentioned, I was also starting to consider an Elixir GenServer that can poll netsuite every 5 mins. Right now mine polls every hour, a limit I set arbitrarily with a solution that at first required pulling in every Job and querying up a few records to get other parent IDs about it.
b
there are occasionally hybrids of the two if the performance hit from a user event is undesirable
m
The user event script sounds interesting and more for the realtime that I'm looking to facilitate.
Are there good guides on that?
b
honestly you probably just want to read everything in SuiteScript 2.x User Event Script Type
user events are the easiest way to destroy performance for the record its deployed to
m
They start to lag stuff?
b
you pay for whatever logic you do in realtime
for every triggering record
m
In my case, I'd really just want to be able to POST to my app where it can make additional queries and computations away from Netsuite.
So I could write a script that would use... what was it...
nlapi
or something to be able to POST messages right? Just need to properly form headers and all?
Before I had no luck with it just trying to send a body to a link without having made headers lol.
b
the only thing about https.post's documentation is that its example is deceptive
m
How do you mean?
b
the
headerObj
it uses is two headers, the name and the value headers
its not one single header with the name
Accept-Language
and the value
en-us
m
So it should be the latter? A single header to have a properly formed POST?
like
['Accept-Language' , 'en-us']
or some object like that?
b
thats extra wrong
thats not even an object
again, the example is 2 headers, name and value
its not the
Accept-Language
header like the values would suggest
m
Hm... Should it be
var headerObj = { "Accept-Language": "en-us" }
?
b
thats what you would want if you wanted a header named
Accept-Language
with a value of
en-us
🙌 1
m
Thank you a ton @battk and @Shane Brown this has been helping out a ton! I'll need some time to study.