Saturday, December 22, 2018

Web Services: Initialize and Add a Vendor Bill from a Purchase Order using C#

The code snippet below shows how to initialize and add a Vendor Bill from a Purchase Order using C#.

InitializeRef purchaseOrder = new InitializeRef();
purchaseOrder.internalId = "4107"; //specify internal id

purchaseOrder.type = InitializeRefType.purchaseOrder;
purchaseOrder.typeSpecified = true;

InitializeRecord vendorBill = new InitializeRecord();
vendorBill.type = InitializeType.vendorBill;
vendorBill.reference = purchaseOrder;

ReadResponse vendorBillResponse = service.initialize(vendorBill);
VendorBill vendorBillRecord = (VendorBill)vendorBillResponse.record;

RecordRef location = new RecordRef();
location.internalId = "1";
location.type = RecordType.location;
location.typeSpecified = true;

vendorBillRecord.itemList.item[0].location = location;

WriteResponse response = service.add(vendorBillRecord);

Note: "service" is an instance of NetSuiteService and must be declared and instantiated accordingly.

No comments:

Post a Comment