Reading an Invoice from NetSuite and Sending to B2B Gateway (1 EDI Source)

On this page

The Challenge

Creating an invoice when a sales order is fulfilled requires that you create the invoice in your ERP system and then manually upload/enter it in the EDI gateway. This is mainly a manual process that utilizes significant time and effort. In addition, it is challenging to handle errors and any changes in the expected schema. 

SnapLogic's B2B solution helps you setup a Pipeline that can automatically create the invoice. This use case demonstrates how you can leverage SnapLogic to create invoices for multiple fulfilled sales orders in NetSuite and then send these invoices to the EDI gateway's SFTP site. 

The SnapLogic Pipeline Solution

The following Pipeline, when executed, creates an invoice for every fulfilled order in NetSuite and sends the invoice to the EDI gateway. 

This Pipeline utilizes an expression library called helpers. You can download and import this expression library and the above Pipeline from the Downloads section below into your SnapLogic org using your own dataset.

This Pipeline performs the following tasks:

Task 1: Reading and Mapping the NetSuite Sales Order

In the use case Creating B2B Transaction -- Sales Order Use Case we wrote the sales order created by NetSuite into a file in the SnapLogic Database (SLDB). We now read this file to retrieve all the sales order data by using the File Reader Snap labelled Read Result. This data is then parsed and sent to the Mapper Snap labelled Get SO Mapper. This Snap is configured to retrieve the Internal ID for each sales order.

The base reference type, salesOrder, and the Internal IDs are sent to the NetSuite Get Snap labelled Get Sales Order.

This enables us to retrieve the order's current state. 

Task 2: Creating the Item Fulfillment

Item fulfillment in any system is a manual process. A sales order is deemed fulfilled only after the merchandise/product/service is shipped. In our use case, we simulate that process by marking the sales orders as fulfilled or _shipped. This process is executed by the Snaps labelled Root Mapper, Item Mapper, and Create Item Fulfillment. All these Snaps work together to provide the Internal ID.

The output from the Root Mapper Snap is passed to the NetSuite Create Snap labelled Create Invoice where the invoices are created.

Task 3: Creating and Processing the Invoice

The NetSuite Create Snap, Create Invoice, is configured to create invoice based on the Internal ID it receives.

From the above output we retrieve only the base reference, type, and Internal ID using the Mapper Snap, Get Invoice Mapper.

We do this since the base reference and Internal ID helps retrieve the invoice's details from NetSuite using the NetSuite Get Snap labelled Get Invoice. This Snap retrieves the invoice's details. From these details we retrieve the Control ID using the Mapper Snap labelled Invoice Mapper.

Now we have all the required information from NetSuite to communicate to the EDI gateway that the sales order sent from it is fulfilled. To do so, we perform two operations:

  1. Sending the invoice to the EDI gateway.
  2. Creating a local record of the invoice.

Sending the invoice to the EDI gateway

The invoice data is formatted as a JSON file and written to the EDI gateway's Out sub-directory using a File Writer Snap. This establishes a communication between the ERP system and the EDI gateway. 

Creating a local record of the invoice

The invoice data is formatted as a JSON file and written into the SLDB. You can write a SnapLogic expression to use the invoice ID and Control ID in the filename to keep it unique and identifiable.

Try it Out

  1. Download the Solution Pipeline and  Expression Library

  2. Log into SnapLogic and click the Import a Pipeline icon in SnapLogic Designer.

  3. Select the Pipeline from your local Drive.

  4. Edit the Pipeline's details such as Label and click Save.

  5. Import the expression library in the Expression Libraries section.

  6. Click Save.

  7. Configure the accounts in the Snaps as appropriate.

  8. Validate and execute the Pipeline.


  File Modified

File helpers.expr

Aug 30, 2019 by Patrick Taylor

File 1EDISource NetSuite Create and Send Invoice.slp

Sep 04, 2019 by Mohammed Iqbal