Friday, July 31, 2020

#788 OIC 4 Netsuite - Implementing a Generic Error Handler

Firstly a big thank you to my colleagues Kishore, Subhani, Devi and Praveen for their support in respect of Netsuite integrations and for providing me with the basis for this blog post.

Many things in life are a necessary evil - error handling in OIC is not one of them. Granted it is extra work, but if you invest the time up front this will greatly accelerate your integration development.

Generic Error Handler 




















In the above example we have 3 options - only one has been implemented, but you can easily extrapolate from this.

Let's start with the trigger definition -

























The fields are self-explanatory - Fault Details will be returned by Netsuite.

Assign Notification Type -













This variable is then checked in the SWITCH Action -












The Notification Action -






















I think this is relatively straightforward, now to leveraging the error handler -

Invoking Generic Error Handler from an Integration


I will now enable error handling on the SurveyMonkey to Netsuite integration, discussed in the previous post.

Here is the starting position - with no error handling implemented -










Granted, this is not the complete integration, but, from what you can see, only the happy path has been implemented.

Now I put the core of the actions - focusing on those related to Netsuite - into a Scope.















Scopes are there for keeping related tasks together, scopes also come with their own Fault Handler.

Now to processing possible Netsuite errors -

Here is the current version of the Netsuite CustomerCheck logic -















I will add a new SWITCH action directly after Check4Customer to check for Netsuite errors -

The data structure returned by Netsuite is as follows -

I check the value of the isSuccess field -













I then select the Throw New Fault Action , if a Netsuite error has occurred.
I configure as follows -

Code -


Reason -













Details -





























I now add a skip condition to skip the case where a customer has not been found.
Netsuite returns the following - "INVALID_KEY_OR_REF" - in such cases.


















So now that the fault has been thrown, let's catch it -

This is where the SCOPE fault handler comes into play.











So here I call the GenericErrorHandler




















I map the fields accordingly

























instanceID is set to -














IntgCode_Version is set to -

a concatenation of identifier and version




notificationType is set to "EMAIL"

fault_code etc. set as follows -












faultDateTime is set to current time.

Ok, so what about the next Netsuite activity?










same modus operandi -

I set the Throw New Fault variables using -



























agus ar uile...

Thursday, July 30, 2020

#787 - OIC - SurveyMonkey 2 Netsuite Synchronisation



Simple Use Case

As the sages say, its a gift to be simple and I'm fully d'accord with that.

I have been asked to detail how to sync contact details from SurveyMonkey to Netsuite.
Ok, said I to myself, let's do it!

It was only afterwards that I started considering what would be a valid use case from a business perspective.

I came up with the following use case -
A B2B scenario - I keep a list of customer contacts in SurveyMonkey.

 

AS you can see, I have 2 customers Commiskey Inc. and MacCumascaigh c.t.
Commiskey Inc has 2 contacts
Mac Cumascaigh c.t. has 1 contact.



Pre-requisites for using the OIC SurveyMonkey adapter


  • A SurveyMonkey Account.
  • A quick perusal of the adapter docs here

Essentially it the same old story, sign in to developer.surveymonkey.com and get the required keys.































Note: on the Settings tab I need to set the redirect url -
https://{OIC_HOST}:{OIC_SSL_PORT}/icsapis/agent/oauth/callback

Now I can create the OIC SurveyMonkey connection -

Step 1 is to upload the SurveyMonkey certificate 






Now to creating the connection - 



































Note: only the Invoke role is supported.














Click Provide Consent













Alles gut!

I now create a scheduled integration to retrieve the Contact Lists/Contacts from SurveyMonkey -








Firstly I leverage the SurveyMonkey adapter to get the ContactLists -






















I then iterate over the results and, for each List,
I invoke SurveyMonkey again, to retrieve the contacts for that list.
























The mapping to Get contacts in list is as follows -











I then log some data to make sure this is working.

So now to my test results -
















































Looks good!

Now to syncing this up with Netsuite - 

Now my logic here is very simple -
ContactList Name = CompanyName in Netsuite

Check if Customer already exists -
If Yes - check if contact already exists, if not - create contact.

If No - create customer and contact(s)

So let's look at the implementation in OIC

Firstly, a caveat - the following does not include error handling - which, naturally, is a must for such.
There is a separate blog post on Netsuite error handling available.

Check if Customer already exists -

















Netsuite connection invoke - 


























Mapping is as follows -












operator is set to "is"

Next step - validate the result of the Search -

I just check the value of totalRecords returned by the search.
If customer not found, I create a new customer in Netsuite - 
























I just map the ContactList name to Netsuite CompanyName.















I store the existing customer/ newly created customer internal id in an instance variable.

Now to the Contact processing, essentially the same modus operandi -
use search to check for existence.

Then use the integration variable containing the customer internalID, when creating the contact.




Create Contact Mapping is as follows -













I create a new Netsuite customer for one of my 2 contact lists - 

















I activate and test -

Here my 2 SurveyMonkey contacts have been added to the existing Netsuite customer - 
Commiskey Inc






A new customer has been created in Netsuite - along with 1 contact



















go raibh maith agaibh go leir agus deireadh seachtaine iontach a bheith agaibh!