How to retrieve sales orders from Netsuite via the API in C#?

How to retrieve sales orders from Netsuite via the API in C#?

Introduction

A SalesOrder is a transaction that records a commitment to sell goods or services to a customer. Sales orders do not affect accounting until the item is shipped or the service is completed. A Salesorder is simply "a transaction that records a promise to sell goods or services to a customer." This is a way for a company to say to a customer, ``I sell this product/service.'' A sales order is a commitment to sell something (as opposed to actually selling something), so it has no impact on the ledger. All financial information (cost of items/services, shipping costs, etc.) will appear on the purchase order, which is not an invoice and will not appear anywhere in your account.

Data Retrieval in Nesuite

There are two data sources available for advanced printing of PDF/HTML journal entries: General Journal Entry SuiteScript Record and GL Impact. You can use one data source to get the template's data, or you can use both data sources to get the data. For example, you can use a SuiteScript dataset to get the data for the template's header, and GL Impact to get the row's data.

Export Data from NetSuite

NetSuite provides an export feature under Settings > Import/Export > Export Tasks > Full CSV Export. For more information, see Get Selected Lists and Reports as CSV Files (CSV Export).

If this export feature does not meet your needs, you can combine the following options to extract detailed data from NetSuite.

  • Retrieve saved search results in a CSV file. For more information, see Get Search Results.
  • Get report results as a CSV file.
  • Create a SOAP web utility to query record data. For more information, see SuiteTalk SOAP Web Services Platform Overview.
  • Use SuiteAnalytics Connect to access NetSuite data through ODBC, JDBC, or ADO.NET drivers and external applications such as Microsoft Excel and Crystal Reports
  • Detailed records obtained from these approaches can be used to create a spreadsheet of relevant information. All of these approaches can preserve the relational aspect of the data as long as they export the internal ID with each row of data.

Here are some steps you can follow:

  • Create a new C# project in Visual Studio.
  • Add a reference to the SuiteTalk WSDL file.
  • Use the WSDL file to generate a proxy class for the SuiteTalk web service.
  • Use the generated proxy class to call the SuiteTalk web service methods.

Data Retrieval/Sales Order

A Sales Order is a transaction that records a commitment to sell goods or services to a customer. Sales orders do not affect accounting until the item is shipped or the service is completed.

Example

I spent a lot of time figuring out how to get the BillAddressListID and ShipAddressListID records associated with a particular sales order. After spending more than a day on this, I found a solution by looking through C# examples. Netsuite's documentation on how to use PHPToolKit is a little premature, and it takes a lot of digging and trial and error to find a solution. If you're new to NetSuite, check out our NetSuite developer resources for easy reference.

Code

Below is a sample of retrieving sales order in C# code that uses a web service to retrieve BillAddressList and ShipAddressList. Please note that a valid login session and an existing sell order are required.

Status stat = nss.login(p).status; if (stat.isSuccess) { // Passing the internal ID of the existing Sales Order.  RecordRef r = new RecordRef();  r.internalId = "630";  r.type = RecordType.salesOrder;  r.typeSpecified = true;  // Passing the get operation into NetSuite    ReadResponse read = nss.get(r);    if (read.status.isSuccess)    {     // Reading the results returned from the get Operation and displaying it in the console.     SalesOrder rec = (SalesOrder)read.record;     Console.Write(rec.shipAddressList.internalId);     Console.Write(rec.billAddressList.internalId);     Console.Read();    }    else    {     Console.Write("Record Not Retrieved");     Console.Read();    } }

*Note* nss is a NetSuiteService object.

About us

Do you need help in services integration? Contact us to start working for your project!

Read More

Are you looking for