Building a Script to Prevent Receipt of Drop Ship Purchase Order

in , , October 25th, 2024

It is possible to create drop-ship purchase orders from a sales order in NetSuite. A drop shipment is when the purchase order to the vendor is shipped directly to the customer, which means the purchase order should not be received. There is a button for drop ship purchase orders to be Mark Shipped, however the Receive Orders page also includes a link to Receive the purchase order. NetSuite has no configuration options to prevent the receipt of a drop-ship purchase order.

Preventing Receipt of a Drop Ship PO in NetSuite

We created a client script that runs on creation of Item Receipt records that shows a warning message that the user is attempting to receive a drop-ship purchase order and gives them a link to mark it shipped instead. It also prevents the user from saving the item receipt with the same warning message to mark it shipped instead.

Script Code Sample to Prevent Receipt of Drop Ship PO

/**
 * @name AG_CS_DropShipReject.js
 * 
 * @author Anchor Group : John Baylon
 * @version 1.0.0
 * @since 2024-10-3
 * 
 * @file reject item receipt creation if purchase order is drop ship
 * 
 * @NApiVersion 2.1
 * @NScriptType ClientScript
*/
define(["N/record", "N/ui/message", "N/search"],
function (record, uiMessage, search) {
    function isPurchaseOrder(id) {
        const type = search.lookupFields({
            type: search.Type.TRANSACTION,
            id: id,
            columns: ['type']
        }).type[0].value;
        log.debug("Type", type);
        return (type == 'PurchOrd');
    }
    function pageInit(context) {
        const createdFrom = context.currentRecord.getValue("createdfrom");
        if (createdFrom && isPurchaseOrder(createdFrom)) {
            const purchaseOrder = record.load({
                type: record.Type.PURCHASE_ORDER,
                id: context.currentRecord.getValue("createdfrom")
            });
            if (purchaseOrder.getValue("dropshipso")) {
                const errorMessage = uiMessage.create({
                    title: "Cannot Receive Drop Shipment Purchase Order",
                    message: "This item receipt is for a drop shipment purchase order. Please <a href='/app/accounting/transactions/itemship.nl?e=T&memdoc=0&transform=purchord&poid=" + purchaseOrder.getValue("id") + "&shipstatus=C&shipgroup=1&id=" + purchaseOrder.getValue("createdfrom") + "&whence='>click here</a> to mark the purchase order as shipped.",
                    type: uiMessage.Type.ERROR
                });
                errorMessage.show();
            }
        }
    }
    function saveRecord(context) {
        const createdFrom = context.currentRecord.getValue("createdfrom");
        if (createdFrom && isPurchaseOrder(createdFrom)) {
            const purchaseOrder = record.load({
                type: record.Type.PURCHASE_ORDER,
                id: context.currentRecord.getValue("createdfrom")
            });
            if (purchaseOrder.getValue("dropshipso")) {
                const errorMessage = uiMessage.create({
                    title: "Cannot Receive Drop Shipment Purchase Order",
                    message: "This item receipt is for a drop shipment purchase order. Please <a href='/app/accounting/transactions/itemship.nl?e=T&memdoc=0&transform=purchord&poid=" + purchaseOrder.getValue("id") + "&shipstatus=C&shipgroup=1&id=" + purchaseOrder.getValue("createdfrom") + "&whence='>click here</a> to mark the purchase order as shipped.",
                    type: uiMessage.Type.ERROR
                });
                errorMessage.show();
                return false;
            }
        }
        return true;
    }
    return {
        pageInit: pageInit,
        saveRecord: saveRecord
    };
});

Key Script Deployment Fields

When deploying this script Applies To needs to be set to Item Reciept, and Event Type needs to be set to Create.

NetSuite Feature Enablement for Drop Ship & Special Orders

This solution is only relevant when the Drop Shipments & Special Orders feature is enabled.

Want to learn more about enabling features in your Netsuite Account? Check out this tutorial article on Enabling Features in NetSuite!

Author: Nathan Wiley


Got stuck on a step in this article?

We like to update our blogs and articles to make sure they help resolve any troubleshooting difficulties you are having. Sometimes, there is a related feature to enable or a field to fill out that we miss during the instructions. If this article didn't resolve the issue, please use the chat and let us know so that we can update this article!

Oracle NetSuite Alliance Partner & Commerce Partner

If you have questions about how our team can support your business as you implement NetSuite or SuiteCommerce, feel free to contact us anytime. Anchor Group is a certified Oracle NetSuite Alliance Partner and Commerce Partner equipped to handle all kinds of NetSuite and SuiteCommerce projects, large or small!

 
 

Want to keep learning?

Our team of NetSuite professionals has written articles on a wide variety of NetSuite topics, from SuiteCommerce tips, to recommended NetSuite solutions, to available support services, and more! 

Your cart