The function to check purchase order is drop ship/special order

/**
 * function to check the purchase order is drop ship /special order
 * @param createdFrom
 * @returns {number}
 */
function checkDropShipOrSpecialOrder(createdFrom) {
    var searchResultCount = 0;
    try {
        var purchaseorderSearchObj = search.create({
            type: "purchaseorder",
            filters:
                [
                    ["type", "anyof", "PurchOrd"],
                    "AND",
                    ["appliedtolinktype", "anyof", "DropShip", "SpecOrd"],
                    "AND",
                    ["internalid", "anyof", createdFrom]
                ],
            columns:
                [
                    search.createColumn({
                        name: "ordertype",
                        sort: search.Sort.ASC,
                        label: "Order Type"
                    }),
                    search.createColumn({name: "tranid", label: "Document Number"}),
                ]
        });
        searchResultCount = purchaseorderSearchObj.runPaged().count;
        log.debug("purchaseorderSearchObj result count", searchResultCount);
        purchaseorderSearchObj.run().each(function (result) {
            // .run().each has a limit of 4,000 results
            return true;
        });


    } catch (e) {
        log.error({
            title: e.name,
            details: e
        });
    }
    return searchResultCount;
}

Leave a comment

Your email address will not be published. Required fields are marked *