RE: Dropship Purchase Order has Receive Button instead of Mark Shipped Button

I have a requirement to create purchase order from sales order in net suite through c# code.

code i have used to create purchase order:

var createPurchaseOrder = new PurchaseOrder();

createPurchaseOrder.entity = new RecordRef()

{

internalId = “653”,

name = “Auto”

//type = RecordType.purchaseOrder,

//typeSpecified = true

};

RecordRef soRecordRef = new RecordRef();

soRecordRef.internalId = soInternalId;

soRecordRef.type = RecordType.salesOrder;

soRecordRef.typeSpecified = true;

createPurchaseOrder.createdFrom = soRecordRef;

RecordRef cFormRecordRef = new RecordRef();

cFormRecordRef.internalId = “106”;

createPurchaseOrder.customForm = cFormRecordRef;

RecordRef depRecordRef = new RecordRef();

depRecordRef.internalId = “15”;

depRecordRef.name = “01-Cash”;

depRecordRef.type = RecordType.department;

depRecordRef.typeSpecified = true;

createPurchaseOrder.department = depRecordRef;

RecordRef locRecordRef = new RecordRef();

locRecordRef.internalId = “1”;

locRecordRef.name = “2439”;

locRecordRef.type = RecordType.location;

locRecordRef.typeSpecified = true;

createPurchaseOrder.location = locRecordRef;

//RecordRef shipToRecordRef = new RecordRef();

//shipToRecordRef.internalId = “139330”;

//createPurchaseOrder.shipTo = shipToRecordRef;

//createPurchaseOrder.supervisorApproval = true;

//createPurchaseOrder.supervisorApprovalSpecified = true;

//createPurchaseOrder.toBeEmailed = false;

//createPurchaseOrder.toBeEmailedSpecified = true;

//createPurchaseOrder.toBeFaxed = false;

//createPurchaseOrder.toBeFaxedSpecified = true;

//createPurchaseOrder.toBePrinted = false;

//createPurchaseOrder.toBePrintedSpecified = true;

//createPurchaseOrder.tranDate = DateTime.Now;

//createPurchaseOrder.tranDateSpecified = true;

//oCustomFieldRefList = new List<CustomFieldRef>();

//BooleanCustomFieldRef ObjBooleanCustomFieldRef = new BooleanCustomFieldRef();

//ObjBooleanCustomFieldRef.scriptId = “custbody_uploaded”;

//ObjBooleanCustomFieldRef.value = true;

//oCustomFieldRefList.Add(ObjBooleanCustomFieldRef);

////StringCustomFieldRef objStringCustomFieldRef = new StringCustomFieldRef();

////objStringCustomFieldRef.internalId = “93”;

////objStringCustomFieldRef.value = “eBay US”;

////oCustomFieldRefList.Add(objStringCustomFieldRef);

////objStringCustomFieldRef = new StringCustomFieldRef();

////objStringCustomFieldRef.internalId = “37”;

////objStringCustomFieldRef.value = “22-05005-77941”;

////oCustomFieldRefList.Add(objStringCustomFieldRef);

////objStringCustomFieldRef = new StringCustomFieldRef();

////objStringCustomFieldRef.internalId = “910”;

////objStringCustomFieldRef.value = “192940280928”;

////oCustomFieldRefList.Add(objStringCustomFieldRef);

//createPurchaseOrder.customFieldList = oCustomFieldRefList.ToArray();

PurchaseOrderItem[] Items = new PurchaseOrderItem[1];

Items[0] = new PurchaseOrderItem();

RecordRef item = new RecordRef();

item.type = RecordType.nonInventoryPurchaseItem;

item.typeSpecified = true;

item.internalId = “62079”;

Items[0].item = item;

oCustomFieldRefList = new List<CustomFieldRef>();

BooleanCustomFieldRef ObjBooleanCustomFieldRef = new BooleanCustomFieldRef();

ObjBooleanCustomFieldRef.scriptId = “custcol_dropship”;

ObjBooleanCustomFieldRef.value = true;

oCustomFieldRefList.Add(ObjBooleanCustomFieldRef);

StringCustomFieldRef objStringCustomFieldRef = new StringCustomFieldRef();

objStringCustomFieldRef.internalId = “220”;

objStringCustomFieldRef.value = “KN-204”;

oCustomFieldRefList.Add(objStringCustomFieldRef);

objStringCustomFieldRef = new StringCustomFieldRef();

objStringCustomFieldRef.internalId = “219”;

objStringCustomFieldRef.value = “K&N|KN-204”;

oCustomFieldRefList.Add(objStringCustomFieldRef);

objStringCustomFieldRef = new StringCustomFieldRef();

objStringCustomFieldRef.internalId = “909”;

objStringCustomFieldRef.value = “KN204”;

oCustomFieldRefList.Add(objStringCustomFieldRef);

Items[0].customFieldList = oCustomFieldRefList.ToArray();

RecordRef customerRecordRef = new RecordRef();

customerRecordRef.internalId = “139330”;

customerRecordRef.type = RecordType.customer;

customerRecordRef.typeSpecified = true;

Items[0].customer = customerRecordRef;

Items[0].rate = “5”;

Items[0].quantity = 1;

Items[0].quantitySpecified = true;

Items[0].department = depRecordRef;

Items[0].expectedReceiptDate = DateTime.Now;

Items[0].expectedReceiptDateSpecified = true;

Items[0].isBillable = false;

Items[0].isBillableSpecified = true;

//Items[0].isClosed = false;

//Items[0].isClosedSpecified = true;

//Items[0].matchBillToReceipt = false;

//Items[0].matchBillToReceiptSpecified = true;

RecordRef unitsRecordRef = new RecordRef();

unitsRecordRef.internalId = “1”;

Items[0].units = unitsRecordRef;

RecordRef soItem = new RecordRef();

soItem.type = RecordType.salesOrder;

soItem.typeSpecified = true;

soItem.internalId = soInternalId;

RecordRef[] soItems = new RecordRef[1];

soItems[0] = soItem;

Items[0].linkedOrderList = soItems;

PurchaseOrderItemList purchaseOrderItemList = new PurchaseOrderItemList();

purchaseOrderItemList.item = Items;

createPurchaseOrder.itemList = purchaseOrderItemList;

WriteResponse response = Service.add(createPurchaseOrder);

if (response.status.isSuccess != true) throw new Exception(response.status.statusDetail[0].message);

The problem i am facing is RECEIVE button is displayed in the purchase order which i have created through this code instead of MARK SHIPPED button.

Please help me to resolve this issue.

Thanks in advance.

arulmani_m Rookie Asked on May 26, 2020 in SuiteApps.
Add Comment
1 Answers

You would need to link the sales order line to the matching purchase order line, which is usually done by line level fields like orderLine for item fulfillments.  The PurchaseOrder schema doesn’t expose the item level links that you would need nor is there an initialize type from sales order to purchase order.

Your best bet is probably setting the createPo field on the Sales Order, and then modifying the created purchase order.

Intermediate Answered on May 26, 2020.

Thank You battk for you reply.

I tried initializing purchase order from sales order, but i got the error “You can not initialize purchaseOrder by referencing salesOrder.”

code i have used to initialize:

InitializeRecord iRecord = new InitializeRecord();
iRecord.type = InitializeType.purchaseOrder;

InitializeRef iRef = new InitializeRef();
iRef.typeSpecified = true;
iRef.type = InitializeRefType.salesOrder;

iRef.internalId = SalesOrderInternalId;
iRecord.reference = iRef;

ReadResponse getInitializeResponse = Service.initialize(iRecord);
if (getInitializeResponse.status.isSuccess != true) throw new Exception(getInitializeResponse.status.statusDetail[0].message);

on May 27, 2020.

I also tried linking purchase order to sales order by specifying the purchase order number  in the CREATEDPO field, after it has been created, but it was not linked to sales order and also not throws any error.

code i have used:

var updateSalesOrder = new SalesOrder();
updateSalesOrder.internalId = salesOrder.internalId;

SalesOrderItem[] soNewItems = new SalesOrderItem[1];

var soNewItem = new SalesOrderItem();

soNewItem = salesOrder.itemList.item[0];

//soNewItem.createPo = ReadCSV.com.netsuite.webservices.SalesOrderItemCreatePo._dropShipment;
//soNewItem.createPoSpecified = true;

RecordRef poItem = new RecordRef();
poItem.type = RecordType.purchaseOrder;
poItem.typeSpecified = true;
poItem.internalId = purchaseOrder.internalId;
soNewItem.createdPo = poItem;

soNewItems[0] = soNewItem;

SalesOrderItemList salesOrderItemList = new SalesOrderItemList();
salesOrderItemList.item = soNewItems;
updateSalesOrder.itemList = salesOrderItemList;

response = Service.update(updateSalesOrder);
if (response.status.isSuccess != true) throw new Exception(response.status.statusDetail[0].message);

The CREATEPO field which you have mentioned only accepts ENUM like ReadCSV.com.netsuite.webservices.SalesOrderItemCreatePo._dropShipment;

on May 27, 2020.

I have also tried providing the line number for the purchase order item same as in the sales order item. still it was not linked to sales order.

code i have used

SearchPreferences searchPreferences = new SearchPreferences();
searchPreferences.bodyFieldsOnly = false;
Service.searchPreferences = searchPreferences;

SearchResult result = Service.search(new TransactionSearch()
{
basic = new TransactionSearchBasic()
{
type = new SearchEnumMultiSelectField()
{
@operator = SearchEnumMultiSelectFieldOperator.anyOf,
operatorSpecified = true,
searchValue = new string[] { “_salesOrder” }
},
tranId = new SearchStringField()
{
@operator = SearchStringFieldOperator.@is,
operatorSpecified = true,
searchValue = soNumber
}
}
});

if (result.status.isSuccess && result.totalRecords == 1)
{
SalesOrder salesOrder = (SalesOrder)result.recordList[0];

var createPurchaseOrder = new PurchaseOrder();

createPurchaseOrder.entity = new RecordRef()
{
internalId = “653”,
name = “Auto”
};

RecordRef soRecordRef = new RecordRef();
soRecordRef.internalId = salesOrder.internalId;
soRecordRef.type = RecordType.salesOrder;
soRecordRef.typeSpecified = true;
createPurchaseOrder.createdFrom = soRecordRef;

RecordRef depRecordRef = new RecordRef();
depRecordRef.internalId = salesOrder.department.internalId;
depRecordRef.name = salesOrder.department.name;
depRecordRef.type = RecordType.department;
depRecordRef.typeSpecified = true;
createPurchaseOrder.department = depRecordRef;

RecordRef locRecordRef = new RecordRef();
locRecordRef.internalId = salesOrder.location.internalId;
locRecordRef.name = salesOrder.location.name;
locRecordRef.type = RecordType.location;
locRecordRef.typeSpecified = true;
createPurchaseOrder.location = locRecordRef;

PurchaseOrderItem[] Items = new PurchaseOrderItem[1];
Items[0] = new PurchaseOrderItem();
Items[0].line = salesOrder.itemList.item[0].line;
Items[0].lineSpecified = true;

RecordRef roItem = new RecordRef();
roItem.type = RecordType.nonInventoryPurchaseItem;
roItem.typeSpecified = true;
roItem.internalId = salesOrder.itemList.item[0].item.internalId;
Items[0].item = roItem;

oCustomFieldRefList = new List<CustomFieldRef>();
BooleanCustomFieldRef ObjBooleanCustomFieldRef = new BooleanCustomFieldRef();
ObjBooleanCustomFieldRef.scriptId = “custcol_dropship”;
ObjBooleanCustomFieldRef.value = true;
oCustomFieldRefList.Add(ObjBooleanCustomFieldRef);
StringCustomFieldRef objStringCustomFieldRef = new StringCustomFieldRef();
objStringCustomFieldRef.internalId = “220”;
objStringCustomFieldRef.value = “KN-204”;
oCustomFieldRefList.Add(objStringCustomFieldRef);
objStringCustomFieldRef = new StringCustomFieldRef();
objStringCustomFieldRef.internalId = “219”;
objStringCustomFieldRef.value = “K&N|KN-204”;
oCustomFieldRefList.Add(objStringCustomFieldRef);
objStringCustomFieldRef = new StringCustomFieldRef();
objStringCustomFieldRef.internalId = “909”;
objStringCustomFieldRef.value = “KN204”;
oCustomFieldRefList.Add(objStringCustomFieldRef);
Items[0].customFieldList = oCustomFieldRefList.ToArray();

RecordRef customerRecordRef = new RecordRef();
customerRecordRef.internalId = “139330”;
customerRecordRef.type = RecordType.customer;
customerRecordRef.typeSpecified = true;
Items[0].customer = customerRecordRef;

Items[0].rate = salesOrder.itemList.item[0].amount.ToString();
Items[0].quantity = salesOrder.itemList.item[0].quantity;
Items[0].quantitySpecified = true;
Items[0].department = depRecordRef;
Items[0].expectedReceiptDate = DateTime.Now;
Items[0].expectedReceiptDateSpecified = true;
Items[0].isBillable = false;
Items[0].isBillableSpecified = true;

RecordRef unitsRecordRef = new RecordRef();
unitsRecordRef.internalId = “1”;
Items[0].units = unitsRecordRef;
RecordRef soItem = new RecordRef();
soItem.type = RecordType.salesOrder;
soItem.typeSpecified = true;
soItem.internalId = salesOrder.internalId;
RecordRef[] soItems = new RecordRef[1];
soItems[0] = soItem;
Items[0].linkedOrderList = soItems;
PurchaseOrderItemList purchaseOrderItemList = new PurchaseOrderItemList();
purchaseOrderItemList.item = Items;
createPurchaseOrder.itemList = purchaseOrderItemList;
WriteResponse response = Service.add(createPurchaseOrder);
if (response.status.isSuccess != true) throw new Exception(response.status.statusDetail[0].message);

Please help to resolve linking the purchase order to sales order and displaying MARK SHIPPED button in the purchase order form.

Thanks in Advance.

on May 27, 2020.

My answer is saying that you cannot link the purchase order and sales order. The fields required to do so simply are not exposed. You should instead approach the problem differently.

My recommendation was to use the createPo checkbox. That checkbox is used to make NetSuite automatically create a related purchase order. That purchase order may not match exactly what you wanted it to look like, which is why you probably want to edit it afterwards.

on May 27, 2020.

Battk,

Thanks for your reply. sales order form is not showing checkbox for the createPo field.Below is the screenshot for your reference.

RE: Dropship Purchase Order has Receive Button instead of Mark Shipped Button

i have also tried below code which marks the dropship checkbox and set dropship enum in createPO field. that too not creating dropship purchase order.

SearchPreferences searchPreferences = new SearchPreferences();
searchPreferences.bodyFieldsOnly = false;
Service.searchPreferences = searchPreferences;

SearchResult result = Service.search(new TransactionSearch()
{
basic = new TransactionSearchBasic()
{
type = new SearchEnumMultiSelectField()
{
@operator = SearchEnumMultiSelectFieldOperator.anyOf,
operatorSpecified = true,
searchValue = new string[] { “_salesOrder” }
},
tranId = new SearchStringField()
{
@operator = SearchStringFieldOperator.@is,
operatorSpecified = true,
searchValue = soNumber
}
}
});

if (result.status.isSuccess && result.totalRecords == 1)
{
SalesOrder salesOrder = (SalesOrder)result.recordList[0];

var updateSalesOrder = new SalesOrder();
updateSalesOrder.internalId = salesOrder.internalId;

SalesOrderItem[] soNewItems = new SalesOrderItem[1];

var soNewItem = new SalesOrderItem();

soNewItem = salesOrder.itemList.item[0];

oCustomFieldRefList = new List<CustomFieldRef>();
BooleanCustomFieldRef ObjBooleanCustomFieldRef = new BooleanCustomFieldRef();
ObjBooleanCustomFieldRef.scriptId = “custcol_dropship”;
ObjBooleanCustomFieldRef.value = true;
oCustomFieldRefList.Add(ObjBooleanCustomFieldRef);

soNewItem.customFieldList = oCustomFieldRefList.ToArray();

soNewItem.createPo = ReadCSV.com.netsuite.webservices.SalesOrderItemCreatePo._dropShipment;

soNewItems[0] = soNewItem;

SalesOrderItemList salesOrderItemList = new SalesOrderItemList();
salesOrderItemList.item = soNewItems;
updateSalesOrder.itemList = salesOrderItemList;

WriteResponse response = Service.update(updateSalesOrder);
if (response.status.isSuccess != true) throw new Exception(response.status.statusDetail[0].message);

}

My requirement is

  1. loop through sales order item to check inventory is available.
  2. if inventory is available then i have to create drop ship purchase order against that sales order line item.

i have created code for creating drop ship purchase order ( i have posted the code in the beginning of this post). the problem i am facing is Mark Shipped button is not displayed in the drop ship purchase order form in net suite instead Receive button is displayed and it was not linked to sales order.

i am expecting Ur help for fixing this issue.

Thanks in Advance.

on May 28, 2020.

My apologies, createPo is an enumeration, not a checkbox. Same idea though, set the createPo field on the item to _dropShipment. You wont get a mark shipped button on a purchase order that is not linked to a sales order’s drop ship item, which is why you need to let netsuite create the purchase order for you. The request xml to add a sales order with the field set should look something like:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:platformMsgs="urn:messages_2020_1.platform.webservices.netsuite.com">
  <soapenv:Header>
    <platformMsgs:tokenPassport>
      <account>{{ACCOUNT_ID}}</account>
      <consumerKey>{{CONSUMER_KEY}}</consumerKey>
      <token>{{TOKEN_ID}}</token>
      <nonce>{{nonce}}</nonce>
      <timestamp>{{timestamp}}</timestamp>
      <signature algorithm="HMAC-SHA256">{{signature}}</signature>
    </platformMsgs:tokenPassport>
  </soapenv:Header>
  <soapenv:Body>
    <add>
      <record xsi:type="tranSales:SalesOrder" xmlns:tranSales="urn:sales_2020_1.transactions.webservices.netsuite.com">
        <customForm internalId="103"/>
        <entity internalId="9"/>
        <orderStatus>_pendingFulfillment</orderStatus>
        <itemList>
          <item>
            <item internalId="5"/>
            <quantity>1.0</quantity>
            <createPo>_dropShipment</createPo>
          </item>
        </itemList>
      </record>
    </add>
  </soapenv:Body>
</soapenv:Envelope>
on May 28, 2020.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.