简体   繁体   English

使用Netsuite SuiteScript使用物料创建销售订单

[英]Creating a Sales Order with an Item using Netsuite SuiteScript

I am attempting to write a Restlet, using SuiteScript 2.0, for my company to create a new Sales Order. 我正在尝试使用SuiteScript 2.0为我的公司编写Restlet,以创建新的销售订单。 I found how to create a record.Type.Sales_Order and put in the minimums for now, but I have no idea on how to create an item for the Sales Order and include it in the SO so I can create the Sales Order. 我找到了如何创建record.Type.Sales_Order并现在放入最小值,但是我不知道如何为销售订单创建项目并将其包含在SO中,这样我就可以创建销售订单。

Here is what I have so far (in a GET): 这是到目前为止(在GET中):

   var salesOrder = record.create({
                type: record.Type.SALES_ORDER, 
                isDynamic: true,
                defaultValues: {
                    entity: param.customer_id
                } 
            });

salesOrder.setValue('trandate', new Date()),
salesOrder.setText('orderstatus','Pending Fulfillment'); 
salesOrder.setValue('memo','Sales Order Generated from ' + param.customer_name);
salesOrder.save();

Do I create a new record of an item type and then add it to the sales order before saving? 我是否要创建商品类型的新记录,然后将其添加到销售订单中,然后再保存? I have looked though the help section in netsuite.com but can't find anything with creating items for a sales order. 我查看了netsuite.com的帮助部分,但在创建销售订单项目时找不到任何东西。

Thanks for any answers or places to look :) 感谢您的任何答案或寻找的地方:)

The item record must exist before adding it to the sales order. 物料记录必须存在,然后才能将其添加到销售订单中。 So if you need to add an item which has not yet been created, you need to create the item record first. 因此,如果需要添加尚未创建的项目,则需要首先创建项目记录。 However, if you're asking how to add an existing item to the item sublist of the sales order, you can do this: 但是,如果您要询问如何将现有项目添加到销售订单的项目子列表中,则可以执行以下操作:

var salesOrder = record.create({
            type: record.Type.SALES_ORDER, 
            isDynamic: true,
            defaultValues: {
                entity: param.customer_id
            } 
        });

salesOrder.selectNewLine({ //add a line to a sublist
    sublistId: 'item'      //specify which sublist
});

salesOrder.setCurrentSublistValue({   //set item field
    sublistId: 'item',
    fieldId: 'item',
    value: {{itemid}}  //replace with item internal id 
});
salesOrder.setCurrentSublistValue({
    sublistId: 'item',
    fieldId: 'quantity',
    value: {{quantity}} //replace with quantity
});

//repeat above pattern to set the rest of the line fields

salesOrder.commitLine({  //writes the line entry into the loaded record
    sublistId: 'item'
});

salesOrder.save({                  //writes record back to database
    ignoreMandatoryFields: true    //set for testing in case you want to create a record without validating which can give errors
});

HTH 高温超导

It depends on how you get your Item details, in case you have items id of an existing one in system, then you can set it using API's 这取决于您如何获取商品详细信息,如果您在系统中拥有现有商品的商品ID,则可以使用API​​的

  • 'selectNewLineItem', 'setCurrentLineItemValue', 'commitLineItem'. 'selectNewLineItem','setCurrentLineItemValue','commitLineItem'。

In case you are getting only the Item name, and its fields details, which does not exist in system, then you have to create a new item using, 如果您仅获得项目名称及其字段详细信息(系统中不存在),则必须使用以下方式创建新项目:

1) var xyz = createRecord('item') 2) use xyz will have an id of created Item, use it to set it in the Sales order. 1)var xyz = createRecord('item')2)使用xyz将具有已创建项目的ID,使用它在销售订单中进行设置。

Note: API's are not exact names, they are just representing their usage. 注意:API并非确切名称,只是代表其用法。

Thanks 谢谢

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM