【问题标题】:Netsuite: Analyzing Line before adding to Sales OrderNetsuite:在添加到销售订单之前分析行
【发布时间】:2020-05-04 11:53:49
【问题描述】:

我正在尝试通过 SuiteScript 创建一个弹出窗口,在将商品添加到订单时,我们将显示可用库存和客户首选品牌以及其他一些详细信息,以便 Cust Svc 代表能够添加正确的 sku 并询问客户在将项目添加到订单之前需要的问题。为此,我需要能够在添加之前访问该项目。我现在设置的弹出窗口确实会显示 - 但我需要我尝试添加的数量和 SKU。当前代码:

/**
 *@NApiVersion 2.x
 *@NModuleScope Public
 *@NScriptType ClientScript
 */
define(['N/search'], runClientscript);

function runClientscript(search){
    SEARCHMODULE = search;

    function validateLine(context) {
       var currentSO = context.currentRecord;
        context.sublistId;
        if(context.sublistId == 'item'){
            alert("validateLine Triggered!");
            var cr = context.currentRecord;
        var quantityLine = currentSO.getSublistValue({
                sublistId : 'item',
                fieldId : 'quantity',
                line : 1
                });
        }
        return true; //Return true if the line insertion is valid.
    }

      /**
         * 
         * @param {object} context context object from user event.
         */
        function getLocationContext(context){
            var contextObj = {};
            contextObj.locationRecord = "customrecord_ship_priority";
            contextObj.warehouseIds = [
                {
                    name:"custrecord_nj_warehouse",
                    value:3
                },
                {
                    name:"one",
                    value:9
                },
                {
                    name:"two",
                    value:8
                },
                {
                    name:"three",
                    value:4
                }
            ]
            contextObj.parameters = getScriptParameter();
            return contextObj;
        }



    var returnObj = {};
    returnObj.validateLine = validateLine;
    return returnObj;
}

任何帮助将不胜感激。谢谢!!

【问题讨论】:

  • 请显示包含数量和 SKU 的表单的 HTML。

标签: javascript netsuite items


【解决方案1】:

请改用currentSo.getCurrentSublistValue({type: 'item', fieldId: '{fieldyouneedtodisplay}'}),它将提供正在添加到验证行的项目的信息。获得所需的所有信息后,就可以像下面的伪代码一样进行验证。

var sItem = currentSo.getCurrentSublistText({type: 'item', fieldId: 'item'});
var nQqty = currentSo.getCurrentSublistValue({type: 'item', fieldId: 'quantity'});
//your code to validate goes after.
if(nQqty >=0){
alert('Adding ' + nQqty  + ' of ' + sItem + '.')
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-10-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多