Tuesday, March 17, 2020

#758 - OIC --> Netsuite adapter - processing Customers

simple example - let's start by creating a customer -

I'm not a Netsuite expert - so I begin by creating a Customer in Netsuite -

Ok, now I've seen the mandatory fields -

So now off to OIC -

I create a simple REST based integration that leverages the Netsuite adapter to create a customer in Netsuite.

Now to the mapping - The Netsuite target has many fields
However, I only map 2

I activate the integration and test -

I check out Customers in Netsuite -

But didn't I enter an invalid Subsidiary - MySub?

Note how it defaults to my Subsidiary -i.e. my Netsuite user is a member of this group.

So what does the response from Netsuite look like?

I map this to my REST response -

Here is my test Request/Response

Only salient data is the InternalId - 10174.
The Internal ID is a unique integer number that is typically called the Table’s Primary Key. 
That integer never changes for the life of the record.

The External ID is an id you can set yourself. For example, if customer was synced with SFDC, this could be the SFDC Id.

I can, of course, use the InternalId to retrieve the customer from Netsuite -

The response from Netsuite is as follows -

I add some more data to my customer in Netsuite -

Here is the OIC response mapping - here I only show mapped fields -

I now test the GET -

Update customer is very easy -

Key again is the Netsuite Internal Id -

I set the comments field to updated by OIC

I validate in Netsuite -

Let's look at Delete -

Same modus operandi -

I test, btw. my integration does a Get, Update, Delete of Customer -
hence the return getCustomer.

Everything seems to have completed successfully -

However, the customer - Commiskey Brewing -  is still in Netsuite -

I now check in the Web Services log of Netsuite -

Note - the delete failed -

I can view the error -

Quite correct - I have the dependent Contact.

So how can I catch this error in OIC?

The response from DeleteCustomer is as follows -

Note we have 2 status sections.
The topmost is for the technical result - e.g. If there was a SOAP error, that would be highlighted here.

The section status section under CustomerRef is what we are interested in.

I map those fields to my response -

I test and get the following response -

Makes sense, Customer has dependent Contacts.

So I add the following process logic to my integration -

Essentially I do a get on Customers - I pass in the InternalId so I will only get one Customer returned. I then loop over the Contacts for the Customer, deleting them.

Finally, I delete the Customer (again).

I activate and test - then check out Netsuite for Commiskey - Brewing -

I check out the Netsuite SOAP Services log -

As you can see, the first delete failed.
Then I did a getList on Customer
Then a deleteList on Contact(s)
Then a deleteList on Customer.

All of which FINISHED successfully.

OIC is so Easy!

No comments: