简体   繁体   中英

Suitescript 1.0 - Get line item units in sales order

I'm trying to get the units text for a sales order in suitescript 1.0 with nlapiGetLineItemText('item','units',i). This works for other select fields such as 'item', but 'units' always returns an empty string. nlapiGetLineItemValue('item','units',i) returns an integer that seems to correspond to specific unit types, but I'm not sure how it relates or if I can use this to extract the units text.

Here's the code:

var lineCount = nlapiGetLineItemCount('item');
var items = [];
var itemObj = {};

var invTypes = ['InvtPart','NonInvtPart','Assembly','Kit'];

for(let i = 1; i <= lineCount; i++) {

    let itemType = nlapiGetLineItemValue('item','itemtype',i);

    if(invTypes.indexOf(itemType) != -1) {
        let itemObj = {
            name:nlapiGetLineItemValue('item','description',i),
            qty:nlapiGetLineItemValue('item','quantity',i),
            units:nlapiGetLineItemValue('item','units',i),
            panel_qty:nlapiGetLineItemValue('item','custcol_panelqty',i),
            panel_ft:nlapiGetLineItemValue('item','custcol_feet',i),
            panel_in:nlapiGetLineItemValue('item','custcol_inch',i)
        };
        console.log(itemObj);
        items.push(itemObj);
    }
}

您可以通过加载来从单位类型记录中提取文本: nlapiLoadRecord('unitstype', nlapiGetLineItemValue('item','units',i)).getFieldValue('name')或通过搜索。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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