如何读取netsuite中的子列表数据?

How to read a sublist data in netsuite?

我是 suitescript 的新手。坦白说我写了两个脚本,看到其他的脚本有点容易。

我的问题是如何从子列表中读取数据并调用其他表单。

这是我的要求。

I want to read the item values data highlighted in yellow color

当我读取变量中的那个特定项时,我想调用 netsuite 中的 assemblyitem 表单并获取一个值。

//Code

function userEventBeforeLoad(type, form, request)
{

nlapiLogExecution('DEBUG', 'This event is occured while ', type);

    if(type == 'create' || type == 'copy' || type == 'edit')
        {
            var recType = nlapiGetRecordType(); //Gets the RecordType
            nlapiLogExecution('DEBUG', 'recType', recType);

            //
            if(recType == 'itemreceipt')
                {
                    nlapiLogExecution('DEBUG', 'The following form is called ',recType);
                    //var itemfield = nlapiGetFieldValue('item')
                    //nlapiLogExecution('DEBUG','This value is = ',itemfield);
                    var formname = nlapiLoadRecord('itemreceipt',itemfield);
                    nlapiLogExecution('DEBUG','This value is = ',formname);

                }

        }

}

我该如何继续?

I want to read that checkbox field value in the following image when i get the item value from above

我建议查看 NetSuite 帮助中的 "Sublist APIs" 页面;它应该描述您将使用的许多方法。

您尤其需要查看 nlobjRecord.getLineItemValue()

这是一个介绍如何在 1.0 和 2.0 中使用子列表的视频:https://www.youtube.com/watch?v=n05OiKYDxhI

我已经为我的目标努力了,并且成功了。答案在这里。

函数 userEventBeforeLoad(类型、表单、请求){

if(type=='copy'|| type =='edit' || type=='create'){

    var recType = nlapiGetRecordType(); //Gets the RecordType
    nlapiLogExecution('DEBUG', 'recType', recType);
    //
    if(recType == 'itemreceipt')
        {
            nlapiLogExecution('DEBUG', 'The following form is called ',recType);
            var itemcount = nlapiGetLineItemCount('item');
            nlapiLogExecution('DEBUG','This value is = ',+itemcount);
            for(var i=1;i<=itemcount;i++)
                {
                    var itemvalue = nlapiGetLineItemValue('item','itemkey',i);
                    nlapiLogExecution('DEBUG','LineItemInternalID = ',itemvalue);
                    var itemrecord = nlapiLoadRecord('assemblyitem', itemvalue);
                    nlapiLogExecution('DEBUG','BOM= ',itemrecord);
                    if(itemrecord == null){
                        var itemrecord = nlapiLoadRecord('inventoryitem', itemvalue);
                        nlapiLogExecution('DEBUG','BOM= ',itemrecord);  
                    }
                    var value = itemrecord.getFieldValue('custitem_mf_approved_for_dock_to_stock');
                    nlapiLogExecution('DEBUG',"Checkboxvalue = ",value);
                    if(value == 'F'){

                        nlapiSetLineItemValue('item','location',i,9);
                        nlapiSetLineItemDisabled ('item','location',false,i );
                    }
                    else{
                        nlapiSetLineItemValue('item','location',i,1);
                        nlapiSetLineItemDisabled ('item','location',true,i );

                    }

                }

        }

}

}