Displaying the availability of items on a sales order from a warehouse

//Info: CDUS-1010

REQUIREMENT 

Would NetSuite be able to show us how many items we have in both warehouses at the same time when we type the SKU? So, when we are entering orders, the system automatically shows us how many items we have in either Miami or Dallas warehouse depending on the primary location or the warehouse that was preferred to the client, but it will be much easier when we enter an SKU, we can see the inventory on both warehouses and then we can pick which SKU is shipping from which warehouse

OUR SOLUTION 

The requirement is achievable by deploying a client Script that will trigger the values based on the Item selected. The execution process will contain the following steps.  

  1. On the item sublist, we’ll create two-column fields. 
  2. The item sublist fields are named ‘AVAILABLE MIAMI’ and ‘AVAILABLE TEXAS.’ 
  3. When a user selects an item, the available Quantities for that item are displayed on each warehouse column field.
function postSourcing(context) {
            try {

                     if (context.fieldId == "item" && context.sublistId == "item") {
                        console.log("Item search");
                        var itemid = context.currentRecord.getCurrentSublistValue({sublistId: 'item', fieldId: 'item'});
                        console.log("item ID", itemid)
                        if (itemid)
                            //search for item warehouse count
                            var itemSearchObj = search.create({
                                type: "item",
                                filters:
                                    [
                                        ["internalid", "anyof", itemid],
                                        "AND",
                                        ["inventorylocation", "anyof", "1", "4"]
                                    ],
                         columns:
                         [
                         search.createColumn({name: "itemid", label: "Name"}),
                         search.createColumn({name: "displayname", label: "Display Name"}),
                                        search.createColumn({
                                            name: "internalid",
                                            join: "inventoryLocation",
                                            sort: search.Sort.ASC,
                                            label: "Internal ID"
                                        }),
      search.createColumn({name: "inventorylocation", label: "Inventory Location"}),
      search.createColumn({name: "locationquantityavailable", label: "Location Available"})
                          ]
                         });
                        var searchResultCount = itemSearchObj.runPaged().count;
                        console.log("itemSearchObj result count", searchResultCount);
                        var searchResult = itemSearchObj.run().getRange({
                            start: 0,
                            end: 10
                        });
               
                        if (searchResultCount > 0) {
                            var item_quantity = searchResult[0].getValue({
                                name: "locationquantityavailable",
                                label: "Location Available"
                            }) || 0;
                        
                            var item_quantity2 = searchResult[1].getValue({
                                name: "locationquantityavailable",
                                label: "Location Available"
                            }) || 0;


                            context.currentRecord.setCurrentSublistValue({
                                sublistId: 'item',
                                fieldId: 'custcol_jj_qua_miami_cdus_1010',
                                value: item_quantity,
                                ignoreFieldChange: false
                            });

                            context.currentRecord.setCurrentSublistValue({
                                sublistId: 'item',
                                fieldId: 'custcol_jj_qua_texas_cdus_1010',
                                value: item_quantity2,
                                ignoreFieldChange: false
                            });
                        }
                    }
            }catch (error) {
                console.log("error @ postSourcing", error);
            }
        }
        return {
            postSourcing: postSourcing
        }

Leave a comment

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