【问题标题】:Netsuite reallocation log issueNetsuite 重新分配日志问题
【发布时间】:2017-12-12 21:39:55
【问题描述】:

更新2:此代码工作pt不会显示原始值,我认为是因为它是在提交之前和提交之后,不知道这是否可以解决

//outputs all items remaining on an realocate thingy
var STOIC = STOIC || {};

STOIC.example = (function () {
    var exports= {};
        // shows original values, does not work, only shows new value.
        function beforeSubmit(type, form, request) {
        var record = nlapiGetOldRecord();
        var itemID = nlapiGetFieldValue('item');
        var lineCount = nlapiGetLineItemCount('order');
        var totalqtyCom = nlapiGetFieldValue('quantitycommitted');
            for ( var i = 1; i < lineCount + 1; i++ )
            {
            var qtyCom = nlapiGetLineItemValue('order', 'quantitycommitted', i);
            var orderNum = nlapiGetLineItemValue('order', 'ordernumber', i);
            var qtyRem = nlapiGetLineItemValue('order', 'quantityremaining', i);
                if(i == 1)
                {
                nlapiLogExecution("DEBUG", "STOIC.example.beforeSubmit",
             "START-BEFORE:" + itemID + ":Order " + orderNum + ", qtyRem " + qtyRem + ", qtyCom" + qtyCom);
                }
                else
                    if(i == lineCount)
                    {
                        nlapiLogExecution("DEBUG", "STOIC.example.beforeSubmit",
                        "END-BEFORE:" + ":Order " + orderNum + ", qtyRem " + qtyRem + ", qtyCom" + qtyCom);
                    }
                else
            nlapiLogExecution("DEBUG", "STOIC.example.beforeSubmit",
            "Order " + orderNum + ", qtyRem " + qtyRem + ", qtyCom" + qtyCom);  
            }


        }

    //shows the new value
    function afterSubmit(type, form, request) {
        var record = nlapiGetOldRecord();
    var itemID = nlapiGetFieldValue('item');
        var lineCount = nlapiGetLineItemCount('order');
    var totalqtyCom = nlapiGetFieldValue('quantitycommitted');
            for ( var i = 1; i < lineCount + 1; i++ )
            {
            var qtyCom = nlapiGetLineItemValue('order', 'quantitycommitted', i);
            var orderNum = nlapiGetLineItemValue('order', 'ordernumber', i);
            var qtyRem = nlapiGetLineItemValue('order', 'quantityremaining', i);
                if(i == 1)
                {
                nlapiLogExecution("DEBUG", "STOIC.example.afterSubmit",
             "START-AFTER:" + itemID + ":Order " + orderNum + ", qtyRem " + qtyRem + ", qtyCom" + qtyCom);
                }
                else
                    if(i == lineCount)
                    {
                        nlapiLogExecution("DEBUG", "STOIC.example.afterSubmit",
                        "END-AFTER:" + ":Order " + orderNum + ", qtyRem " + qtyRem + ", qtyCom" + qtyCom);
                    }
                else
            nlapiLogExecution("DEBUG", "STOIC.example.afterSubmit",
            "Order " + orderNum + ", qtyRem " + qtyRem + ", qtyCom" + qtyCom);  
            }
    }
    function beforeLoad() { // will not fire
        nlapiLogExecution("DEBUG", "STOIC.example.beforeLoad",
                        "testing?");
    }

    exports.beforeSubmit = beforeSubmit;
    exports.afterSubmit = afterSubmit;
    exports.beforeLoad = beforeLoad;
    return exports;
}



)();

更新:所以对于重新分配页面 id 想要它 - 计算行数 - 使用 for 循环输出订单号、客户和承诺数量。 - 我希望它在提交之前和提交之后都运行。这应该让它向我展示原始承诺的数量和现在承诺的新数量。 使用 var lineCount = nlapiGetLineItemCount('quantitycommitted');

似乎它可以让我知道行数,但是却得到了“-1”。

原创 我是一名新管理员,我一直在试图找出我们一直存在的这个长期问题。 我需要在重新分配项目页面中编写一个脚本,以便每当有人更改该页面上的值时, 执行日志会吐出被更改的项目、已提交数量的先前值和已提交数量的新值。 我在 netsuit、支持网站和论坛上四处寻找,没有发现任何有用的东西。 我不确定 netsuite 内部会调用 qty committed。

这是据我所知 api 1.0

var STOIC = STOIC || {};
STOIC.example = (function () {
  var exports= { };
  function beforeSubmit(item) {
    var NumLines= nlapisGetLineItemCount(‘item’);
    for ( var I = 1; i < NumLines + 1; i++)
      // something along the lines of…
      // if ( original quantity* != current qty*)
      //nlapiLogExecution(“debug”, ???, itemname* “old:” + original qty + “ new:” + new qty*);
})();

*netsuite 在内部如何称呼这些?

非常感谢

【问题讨论】:

    标签: javascript logging netsuite


    【解决方案1】:

    您可以在记录浏览器中找到可供 SuiteScript 使用的可用标准字段和子列表。 Here 是有关重新分配项目事务类型的文档。

    • 注意:该链接使用标准 system.netsuite.com/.... url。相应地修改它以适用于您登录的任何数据中心(即 system.na1、system.na2、system.sandbox 等)

    【讨论】:

    • 所以我能够让它输出项目 ID,但无论出于何种原因,它都不会给我总行数。 --- var lineCount = nlapiGetLineItemCount('quantitycommitted'); --- 我想让它循环并转到每一行并吐出订单号、客户和承诺的数量。看看其他例子,使用那行代码应该让我得到除了'-1'之外的东西
    • 如果您查看我提供的链接中的文档,您会看到“重新分配项目”页面上只有 1 个子列表,该子列表称为“订单”。 nlapiGetLineItemCount() 要求传入子列表内部id,'quantitycommitted' 不是子列表。
    • 我刚刚想通了,谢谢。我完成了脚本的主要部分,我只能让它显示数量的更改值,而不是原始数量。我不确定这是否可以纠正,因为脚本只能在提交之前和提交之后触发。 (见新的更新)
    • nlapiGetOldRecord() - 在 beforeLoad、beforeSubmit 和 afterSubmit 用户事件脚本中可用。
    • with -record = nlapiGetOldRecord() ... var qtyCom = record.nlapiGetLineItemValue('order', 'quantitycommitted', i); - 它说“无法调用 null 的方法“nlapiGetLineItemValue””用于重新分配,我不确定它是否被视为记录。看起来它更像是一个过滤保存的搜索。
    猜你喜欢
    • 2015-02-23
    • 1970-01-01
    • 1970-01-01
    • 2016-10-31
    • 2011-09-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多