首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >映射/减少脚本未正确执行(Suitescript2.0)

映射/减少脚本未正确执行(Suitescript2.0)
EN

Stack Overflow用户
提问于 2021-12-15 12:49:20
回答 1查看 414关注 0票数 0

我面临一个奇怪的问题,我的代码(特别是record.save操作)似乎没有被执行。代码位于trescript2.0映射/减少脚本的“还原”阶段。

我不知道这是什么原因。如下面的示例所述,日志记录确实显示“是已执行的”,但下面的行似乎没有被执行。日志记录不显示使用ID标记为order的“订单行”:

代码语言:javascript
复制
//load the order
    var SOrecord = record.load({
        type: record.Type.SALES_ORDER,
        id: orderId,
        isDynamic: false
    });

     setLineValues(SOrecord, values, newShipmentId)

    log.debug('Is this executed?');
    
    //Save Order
    var recId = SOrecord.save({enableSourcing: false, ignoreMandatoryFields: true});
    
    log.debug('Order lines marked for order with ID: ', recId)
    
    return recId;

有人能帮忙吗?

更新

代码语言:javascript
复制
//load the order
    var SOrecord = record.load({
        type: record.Type.SALES_ORDER,
        id: orderId,
        isDynamic: false
    });

    log.debug('Order Loaded! ', SOrecord);
    //Loop lines present in values array
    for(var i = 0; i < values.length; i++){
        //Generate Shipment Line ID, 3 digits starting at 001
        var tmpShipmentLineId = i + 1
        var shipmentLineId = tmpShipmentLineId.toString().padStart(3, '0');
        log.debug('Shipment Line ID: ', shipmentLineId)
        //check if first fulfillment is done, if yes mark ready for second fulfillment
        if(SOrecord.getSublistValue({sublistId: 'item', fieldId: 'custcol_il_send_ff_interface', line: values[i]}) == true){
            log.debug('Line: ' + i, 'Mark ready for 2nd fulfillment')
            //Set values
             SOrecord.setSublistValue({
                sublistId: 'item',
                fieldId: 'custcol_send_to_ff_2nd',
                line: Number(values[i]),
                value: true
            });
              SOrecord.setSublistValue({
                sublistId: 'item',
                fieldId: 'custcol_shipment_id_2nd',
                line: Number(values[i]),
                value: newShipmentId
            });
              SOrecord.setSublistValue({
                sublistId: 'item',
                fieldId: 'custcol_shipment_line_id_2nd',
                line: Number(values[i]),
                value: shipmentLineId
            });

        }
    //If not, mark ready for first fulfillment
        else{
            log.debug('Line: ' + i, 'Mark ready for first fulfillment')
            //Set Values
             SOrecord.setSublistValue({
               sublistId: 'item',
               fieldId: 'custcol_il_send_ff_interface',
               line: Number(values[i]),
               value: true
            });
            SOrecord.setSublistValue({
                sublistId: 'item',
                fieldId: 'custcol_shipment_id',
                line: Number(values[i]),
                value: shipmentId
            });
            SOrecord.setSublistValue({
                sublistId: 'item',
                fieldId: 'custcol_shipment_line_id',
                line: Number(values[i]),
                value: shipmentLineId
            });

        }   

    };

    log.debug('SOrecord after changes: ', SOrecord);

    SOrecord.save();

    log.debug('Record Saved ', 'END');

在上面您会发现一个扩展的代码片段,由于某种原因,for循环之外的所有代码似乎都没有被执行.有什么想法吗?

EN

回答 1

Stack Overflow用户

发布于 2022-01-19 13:46:24

我不太明白这里的代码设置.文本引用了第一个代码片段,但第二个代码片段似乎更具有信息性。这里是一些我会尝试的一般事情,但如果你澄清什么是打印和什么不在第二个代码片段,也许我可以帮助更多.

(1)添加一个try catch,以便更好地处理错误。您似乎收到了一个没有被记录的错误。

(2)尝试以动态模式加载记录,并使用selectLine -> setCurrentSublistValue -> commitLine。

(3)你似乎用的是“行:值:我”,我没有什么返回的例子,但似乎应该是“行:我”。

(4)您是否记录了这个- SOrecord.getSublistValue({sublistId:'item',fieldId:'custcol_il_send_ff_interface',行: value })-如果没有,请告诉我们值是什么.

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/70363978

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档