Friday, June 19, 2020

#781 - Netsuite REST API




As always, a good place to start - the REST API docs from Netsuite, available here

In this post I detail how to call Netsuite REST apis from Postman.

Step 1 - Ensure REST apis are enabled on your Netsuite account

Setup Manager - Company - Enable Features - Suite Cloud(Tab)














Analytics (Tab)

enable SuiteAnalytics Workbook













Step 2 - Create an Integration for TBA (Token Based Auth)

Setup Manager - Integrations - Manage Integrations - New

























save the Client Credentials somewhere, we will need them later.
Consumer Key/Consumer Secret.


Step 3 - Ensure you have a Role with the following Permissions

REST Web Services
Log in using Access Tokens
SuiteAnalytics Workbook

I am using a role eCommerceManager







Under Setup, add -

Log in using Access Tokens - Full
REST Web Service - Full





Under Reports, add - 

SuiteAnalytics Workbook - Edit


Step 4 - Create an Access Token

























Select the Integration application you created.
Specify your user and Role






















Note the Token ID/Secret, we will need them later.

Step 5 - Download the Postman pack from Netsuite

 https://yourNetsuiteAccount.app.netsuite.com/app/external/integration/integrationDownloadPage.nl















Unzip - 









Import the request collection and the environment into Postman

Edit the template -











Make sure to enter your Account_Id in uppercase -
















Note: company url format is - 

https://yourNetsuiteAccount.suitetalk.api.netsuite.com

Step 6 - Test the REST API


























alcoholRecipientType is set to CONSUMER - how true.

Tuesday, June 16, 2020

#780 OIC --> Netsuite Asynchronous Request Processing



Another feature supported by the OIC Netsuite adapter -

With asynchronous requests, your client application sends a request to SOAP web services, where it is placed in a processing queue and handled asynchronously with other requests. Your client application does not wait for a response but goes on to other work. After a job is submitted, a job Id is returned in the SOAP web services response. Your client application can then check on the status and result of the request by referencing the job Id.

Asynchronous processing may be advantageous in the following situations:
- If you expect your connection to NetSuite to be slow or unstable.
- If your job is large, and its processing can be postponed until off-peak hours.
Be aware that asynchronous responses may not be returned immediately. Before committing to using
asynchronous operations, you should consider this factor and decide whether it fits in with your business logic.

Above description taken from the Netsuite Web Services doc here

Here is a very simple example of leveraging this feature, when creating a new customer.

This is the synchronous version of such an integration, now to change this to asynchronous -








Step 1 - Add an Assign Activity to create the following 2 variables.
They will be used later on.


Step 2 - Create a WHILE loop


















Step 3 - Add the Netsuite Invoke to Create Customer


Configure as follows -



















Map as follows - note - I only map jobId and companyName


Step 4 - Add an Assign Action after the Netsuite Invoke -

Here we set the JobId and StatusValue values to the response from Netsuite -



Step 5 - Add a SWITCH Action 

Here we check the value of StatusValue

IF Completed, I then check which flavour - done in the SCOPE - 
ProcessResult.


In the SCOPE, I set the response, based on the outcome.

IF NOT Completed - the Otherwise path is empty - 
but I could do some other processing, if my use case required such. 
I could also add a WAIT.


Activate and Test -


Check out the OIC Tracking page for this instance -

One can follow the async request processing in the Activity Stream -










Monday, June 15, 2020

#779 OIC --> Invoking Netsuite Saved Searches / Miscellaneous



















I created the above Saved Search in Netsuite.
Filter is simply -







Now to using this in OIC -



























































Here I can add response columns -


































A MAP action is added before the invoke of the saved search -
but I leave this blank for the moment.












I currently have 13 Irish customers in Netsuite -


I test the integration and check out the SavedSearch response in the Activity Stream.






















The first 5 (see pageSize) of the 13 customers have been returned.
So how can I increase this number?

























Activate and Test -


























All 13 customers are returned.
Naturally, one could also paginate over search result, reducing the data returned.

Miscellaneous

So what I am referring to here?
















So let's try this out - I am interested in the following item -


















I check out the stock in Netsuite -











San Francisco has 228 bikes on hand.
Boston - 440 bikes.

I map the internalID -


















Activate and test - check the result in the OIC Activity Stream -