Saturday, May 4, 2019

C# > Retrieving BillAddressListID and ShipAddressListID from a sales order

Below is sample code via C# to retrieve the BillAddressList and ShipAddressList using web services. Please note that you must have a valid login session and you must have an existing sales order.
*Note* nss is the NetSuiteServiceObject.

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();
   }
}

No comments:

Post a Comment