0
votes

I'm needing to create drop ship purchase orders against sales orders within NetSuite that already exist and have one or more drop ship POs created against it. Now, normally through the UI you can just click the "Drop Ship" link on an item line and there you go, but this is being done programmatically with SuiteScript. I thought I had this figured out years ago, but it was years ago, this hasn't come up since, and I can no longer remember what files I may have been working on at the time.

The system won't allow reverting the order to a "Pending Approval" status, so I can't just change statuses around to force the system to create the new POs. I've also tried the following to no success:

soRecord.setCurrentLineItemValue("item", "createpo", "DropShip");
soRecord.setCurrentLineItemValue("item", "povendor", vendorId);

Nothing happens aside from adding the new item lines to the sales order. I've also tried creating a PO with the appropriaate vendor and attaching it to the item line on the sales order with the following, but it also has no effect:

soRecord.setCurrentLineItemValue("item", "createdpo", poId);

Is there something I'm missing? Or have I been embarking on a fool's errand the entire time?

2

2 Answers

1
votes

Those fields are read only. This is what I used

var po = nlapiCreateRecord('purchaseorder', {recordmode:"dynamic", soid:<internal id of salesorder>,poentity:<preferred vendor of item>});
0
votes

We had an issue where our auto-drop ship POs stopped generating on SO creation. In an afterSubmit UE deployed to SOs, gather an array of vendors on the item lines and then filter to remove duplicates. Then add this logic inside of a for-loop where i < length of filtered vendor array:

var createDSPO = record.create({
                            type: record.Type.PURCHASE_ORDER,
                            defaultValues: {
                                soid: <SO internal id>,
                                shipgroup: 1,
                                dropship: true,
                                custid: <SO customer internal ID>,
                                entity: poVendorArray[i],
                                poentity: poVendorArray[i]
                            }
                        });
                        createDSPO.save();

FYI, if you inspect the "Drop Ship" link on the SO record, you'll see why I did this. You may be able to figure out another way to do this.