为所选项目创建商品履约。

huangapple go评论61阅读模式
英文:

Create Item fulfillment for selected items

问题

这是我的Suitelet 2.0,我想要为所选项目创建物品履行,并且如果项目、数量和批号与销售订单的项目、数量和批号不匹配,则显示错误消息。否则创建物品履行。请帮忙!

var form = serverWidget.createForm({
  title: "创建物品履行"
});
form.addSubmitButton({ label: '提交' });

var soNumber = form.addField({
  id: 'custpage_so_number',
  type: serverWidget.FieldType.TEXT,
  label: '销售订单号'
});

var sublist = form.addSublist({
  id: "item_sublist",
  type: serverWidget.SublistType.INLINEEDITOR,
  label: "物品"
});
sublist.addField({
  id: "itemname",
  type: serverWidget.FieldType.SELECT,
  label: "物品",
  source: "item"
});
sublist.addField({
  id: "lotnumber",
  type: serverWidget.FieldType.TEXT,
  label: "批号/炉号"
});
sublist.addField({
  id: "quantity",
  type: serverWidget.FieldType.TEXT,
  label: "数量"
});
}
catch(e)
{
    log.debug("获取时出错", e);
}

context.response.writePage(form);

}
else if (context.request.method === 'POST') {

    try{
log.debug("Suitelet正在提交")

    }catch(er)
    {
        log.debug("提交方法中出错", er);
    }
    
}
}
英文:

This is my suitelet 2.0 and I want to create item fulfillment for selected items also shows the error message if the item, quantity, and lot number do not match with the sales order item, quantity, and lot number. else create item fulfillment. Please help!
var form = serverWidget.createForm({
title: "Create Item Fulfillment"
});
form.addSubmitButton({ label: 'Submit' });

          var soNumber = form.addField({
            id : 'custpage_so_number',
            type : serverWidget.FieldType.TEXT,
            label : 'Sales Order Number'
        });

        var sublist = form.addSublist({
            id: "item_sublist",
            type: serverWidget.SublistType.INLINEEDITOR,
            label: "Item"
          });
          sublist.addField({
            id: "itemname",
            type: serverWidget.FieldType.SELECT,
            label: "Item",
            source: "item"
          });
          sublist.addField({
            id: "lotnumber",
            type: serverWidget.FieldType.TEXT,
            label: "Lot/Heat Number"
          });
          sublist.addField({
            id: "quantity",
            type: serverWidget.FieldType.TEXT,
            label: "Quantity"
          });
    }
    catch(e)
    {
        log.debug("error in get",e);
    }

    context.response.writePage(form);

    }
    else if (context.request.method === 'POST') {

        try{
    log.debug("suitelet is posting")
      
        }catch(er)
        {
            log.debug("error in post method",er);
        }
        
    }
}

});

答案1

得分: 0

以下是翻译好的部分:

你的代码非常简洁但没有演示数据是否加载到你在Suitelet中创建的字段中根据你分享的内容你需要添加另一列允许用户选择他们要履行的项目

示例 - 在你的Suitelet中添加一个可点击的复选框

sublist.addField({ id: 'custpage_apply', label: '选择要履行的项目', type: serverWidget.FieldType.CHECKBOX });

接下来你需要在代码的POST语句中读取这个新复选框只有当复选框被标记为TRUE时才尝试履行订单

示例

...上面的GET代码....
else if (context.request.method === 'POST') {

    //开始:创建履行对象,链接到销售/采购订单:
    var objRecord = record.transform({
        fromType: record.Type.SALES_ORDER,
        fromId: {id},
        toType: record.Type.ITEM_FULFILLMENT,
        isDynamic: false,
    });

    try{
        //获取表格行数
        var getCount = context.request.getLineCount('item_sublist');
        
        for (var i = 0; i < getCount; i++) {
            var isApply = context.request.getSublistValue({
                group: 'item_sublist',
                name: 'custpage_apply',
                line: i
            });

            if (isApply == 'T') {
     
                 //添加代码以跟踪和标记匹配的项目以履行
                 
            }
        }
         
        record.save(objRecord);
        context.response.write('履行现已保存');

  
    }catch(er)
    {
        log.debug("post方法中发生错误",er);
        context.response.write('发现错误 ' + er);

    }
    
}
英文:

Your code is very brief and does not demonstrate whether data is loading into the fields you have created in your Suitelet. Working with what you have shared, you will want to add another column that would allow a user to SELECT the item they want to fulfill.

Example - adding a clickable checkbox in your Suitelet:

    sublist.addField({ id: &#39;custpage_apply&#39;, label: &#39;Select Item to Fulfill&#39;, type: serverWidget.FieldType.CHECKBOX });

Next, you will want to read this new checkbox in your POST statement of the code; whereby you only attempt to fulfil an order when the checkbox is marked TRUE.

Example:

...GET code above....
else if (context.request.method === &#39;POST&#39;) {
//BEGIN: Create fulfillment object, link to sales/purchase order:
var objRecord = record.transform({
fromType: record.Type.SALES_ORDER,
fromId: {id},
toType: record.Type.ITEM_FULFILLMENT,
isDynamic: false,
});
try{
//Capture table line count
var getCount = context.request.getLineCount(&#39;item_sublist&#39;);
for (var i = 0; i &lt; getCount; i++) {
var isApply = context.request.getSublistValue({
group: &#39;item_sublist&#39;,
name: &#39;custpage_apply&#39;,
line: i
});
if (isApply == &#39;T&#39;) {
//ADD CODE TO TRACK and MARK MATCHING ITEM TO FULFILL
}
}
record.save(objRecord);
context.response.write(&#39;FULFILMENT NOW SAVED&#39;);
}catch(er)
{
log.debug(&quot;error in post method&quot;,er);
context.response.write(&#39;ERROR FOUND &#39; + er);
}
}

huangapple
  • 本文由 发表于 2023年6月2日 11:30:25
  • 转载请务必保留本文链接:https://go.coder-hub.com/76386959.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定