X

The Integration blog covers the latest in product updates, best practices, customer stories, and more.

  • October 11, 2019

A Simple Guide to Asynchronous calls using Netsuite Adapter

Ankur Prakash
Software Development Manager

The Oracle Netsuite Adapter provides a no-code approach for building integrations with Netsuite. The current Netsuite adapter in Oracle Integration Cloud already allowed the user to make synchronous CRUD calls to Netsuite and also provided extensive Search capabilities. With a new update, we are now adding support to perform all the above operations as asynchronous calls against Netsuite. As we would see in this post, the user can configure a simple toggle during Netsuite invoke configuration and let the adapter internally handle all the intricacies of asynchronous processing like submitting the asynchronous job, checking for its status and getting the results without the user needing to configure separate invokes for each.

How to configure Netsuite Adapter to make Asynchronous Calls?

When configuring an invoke activity using a Netsuite connection on the orchestration canvas, the user can now toggle between Synchronous or Asynchronous calls on the Netsuite Operation Selection Page by selecting the appropriate Processing Mode as shown in the image below. This selection is valid for Basic (CRUD) and Search operation types. Note that Miscellaneous operations don't support asynchronous invocations. The user can also click on the Learn More About Processing Mode link next to the Processing Mode option in the configuration wizard to get inline help on the feature.

How to model an Orchestration Flow with Netsuite invoke configured for Asynchronous Basic (CRUD) operations?

As mentioned above, the user can configure a particular Netsuite invoke to use the Asynchronous processing mode by selecting the appropriate radio button during the endpoint configuration. Once configured, the Netsuite endpoint thus created, will automatically either submit a new asynchronous job or check the job status and get the results based on certain variables being mapped properly. Below is a typical flow modeled to utilize a Netsuite invoke configured to make an asynchronous basic operation call.

Lets look at the high level steps involved in properly modelling an orchestration flow as shown above ...

1. The Integration flow can either be App Driven Orchestration or a Scheduled Orchestration flow.

2. At the beginning of the flow, before invoking Netsuite Asynchronous operation, the user must create and initialize the following two variables → jobId and jobStatus. Care should be taken while initializing the values of these variables to ensure the condition defined in the next step is satisfied the first time, for e.g., use -1 as the initial value. (This step is represented by initializeVariables in the flow diagram above)

3. Create a While loop activity and provide the condition as → $jobStatus != "finished" and $jobStatus != "finishedWithErrors" and $jobStatus != "failed"

4. In the request Map activity to the Netsuite invoke configured to make asynchronous calls, apart from the mappings required for the business use case, the user must map the jobId variable created in step 2 to the jobId defined in the Netsuite request schema under the AsyncJobParameters element as shown in the image below

5. After the Netsuite invoke activity, the user should use the Assign activity to assign jobId and jobStatus variables created in step 2 with values from the response of the Netsuite invoke activity. (This is represented by ReAssignVariables in the flow diagram shown at the beginning of this section.)

6. The user can now configure a Switch activity with either the following condition or a variation of the same based on the business needs...

If we follow the condition above, this switch activity would result in two routes being created in the flow...

6.a. jobStatus is either finished or finishedWithErrors or failed → The user can now get the results from the Netsuite invoke activity's response and based on the business needs, can process the results. For e.g. for an add customer asynchronous job, if the job finished successfully without errors, the user can get the internalId's of the created Customer records...

6.b. jobStatus is neither of the above values → This means that the asynchronous job is still running. Hence before we can get the job results, one can either do certain other operations or wait and loop back to the while loop created in step 3.

Thus, as can be seen from this example, Netsuite adapter will automatically either submit a new asynchronous job or check the job status and get the results based on the jobId being passed in the request.

How to model an Orchestration Flow with Netsuite invoke configured for Asynchronous Search operations?

This is pretty similar to how we model for Asynchronous basic (CRUD) operations, the only differences arising due to the fact the result returned is paginated. Below is a typical flow modeled to utilize a Netsuite invoke configured to make an asynchronous search operation call.

Lets look at the high level steps involved in properly modelling an orchestration flow as shown above ...

1. The Integration flow can either be App Driven Orchestration or a Scheduled Orchestration flow.

2. At the beginning of the flow, before invoking Netsuite Asynchronous operation, the user must create and initialize the following three variables → jobId, pageIndex, totalPages. Care should be taken while initializing the values of these variables to ensure the condition defined in the next step is satisfied the first time, for e.g., use -1 as the initial value. (This step is represented by InitializeVariables in the flow diagram above)

3. Create a While loop activity and provide the condition as → integer( $pageIndex) <= integer( $totalPages)

4. In the request Map activity to the Netsuite invoke configured to make asynchronous calls, apart from the mappings required for the business use case, the user must map the jobId and pageIndex variable created in step 2 to the jobId and pageIndex defined in the Netsuite request schema under the AsyncJobParameters element as shown in the image below

5. After the Netsuite invoke activity, the user should use the Assign activity to assign jobId variable created in step 2 with values from the response of the Netsuite invoke activity. (This is represented by ReAssignVariables in the flow diagram shown at the beginning of this section.)

6. The user should now configure a Switch activity with the condition to check if the status of the submitted job is finished ...

This switch activity would result in two routes being created in the flow...

6.a. status is finished → In this route, the user should create an Assign activity (represented by IncrementPageIndex in the flow diagram shown at the beginning of this section) which increments the pageIndex variable and assign the totalPages variable with the actual value from the results of the asynchronous job performed in the Netsuite invoke. The two images below show the two assignments needed in this Assign activity.

For pageIndex variable...

For totalPages variable ...

The user can now get the results from the Netsuite invoke activity's response and based on the business needs, can process the results. For e.g. for an search customer asynchronous job, if the job finished successfully without errors, the user can get the Customer records which were searched for ...

6.b. status is anything other than finished → This is route 2 of the Switch activity introduced in step 6 above. This means that the asynchronous job is either still running, finishedWithErrors or failed. The user should introduce another Switch activity in this route to deal with jobs which are finishedWithErrors or failed. The otherwise condition for new Switch activity would mean that the job is still running, in which case the control should loop back to while loop created in step 3.

Thus, as can be seen from this example, Netsuite adapter now allows the user to make use of its extensive Search capabilities in an Asynchronous mode with full support for retrieving the paginated result set.

How to request this feature?

This feature is currently in controlled availability (Feature Flag → oic.cloudadapter.adapter.netsuite.AsyncSupport) and available on request. To learn more about features and "How to Request a Feature Flag", please refer to this blog post.

Be the first to comment

Comments ( 0 )
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.