自定义记录/自定义子记录上的已提交子列表行未链接到主记录 [英] Submitted sublist lines on custom record/custom subrecord not linking to main record

查看:59
本文介绍了自定义记录/自定义子记录上的已提交子列表行未链接到主记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我先前的问题的继续: Suitescript代码无明显原因而停止

Continuation of my previous question: Suitescript Code stops for no apparent Reason

未保存/创建子记录(子列表项)并将其链接到父记录.代码如下.

The child record (sublist items) are not being saved/created and linked to the parent record. The code is below.

try {
    var vendorid = nlapiGetRecordId();              console.dir('Vendor ID: #'+vendorid);
    var vprRecordID = create_VPR_record(vendorid);  console.dir('Record Created: #'+vprRecordID);
    var newVprRecord = nlapiLoadRecord('customrecordvendorpricereview', vprRecordID);
    var vendorItems = getVendorItems(vendorid);
    var numberItems = vendorItems.length;
    for (var i=1; i<numberItems; i++ ) {
        newVprRecord.selectNewLineItem(SUBLIST_Items);
        var itemID = parseInt(vendorItems[i].getId());
        var iType = itemType(itemID);
        newVprRecord.setCurrentLineItemValue(SUBLIST_Items,'custrecordvpri_item',itemID);
        var avgCost  = Round(nlapiLookupField(iType,itemID,'averagecost'),4);
        var stdCost  = Round(nlapiLookupField(iType,itemID,'custitem_costrepl'),4);
        var lastCost = Round(nlapiLookupField(iType,itemID,'lastpurchaseprice'),4);
        if (isNaN(avgCost))  { avgCost  = '' };
        if (isNaN(stdCost))  { stdCost  = '' };
        if (isNaN(lastCost)) { lastCost = '' };
        newVprRecord.setCurrentLineItemValue(SUBLIST_Items,'custrecordvpri_costavg',  avgCost );
        newVprRecord.setCurrentLineItemValue(SUBLIST_Items,'custrecordvpri_costlast', lastCost );
        newVprRecord.setCurrentLineItemValue(SUBLIST_Items,'custrecordvpri_coststd',  stdCost );
        newVprRecord.setCurrentLineItemValue(SUBLIST_Items,'custrecordvpri_vendorcurrency',vendorItems[i].getValue('vendorpricecurrency'));
        newVprRecord.setCurrentLineItemValue(SUBLIST_Items,'custrecordvpri_currentprice',vendorItems[i].getValue('vendorcost'));
        newVprRecord.commitLineItem(SUBLIST_Items);
        log('Commit Line #'+i+'  Item ID: '+itemID+'  '+vendorItems[i].getValue('itemid'));
    }
    var linecount = newVprRecord.getLineItemCount(SUBLIST_Items);   console.dir('Line Count #'+linecount );
    nlapiSubmitRecord(newVprRecord);  console.dir('Resubmitting Record #'+vprRecordID+'\n\n'+newVprRecord );
    var url = nlapiResolveURL('record', 'customrecordvendorpricereview', vprRecordID, 'edit');
    window.open(url, "New Vendor Price Review");
} catch (err) { 
    logError(err,'Create_VPR_Main')
}

将子记录链接到主记录的字段是custrecordvpri_header,并作为子列表名称recmachcustrecordvpri_header输入.

The field linking the child records to the main record is custrecordvpri_header, and entered as the sublist name recmachcustrecordvpri_header.

linecount显示为-1

linecount after the for loop is showing -1

推荐答案

您似乎在浏览器上打开的当前客户记录上设置子列表,并且正在nlobjRecord

It looks like you are setting sublist on current client record opened on browser and you are doing submit on a nlobjRecord

//This is the nlobjRecord

var newVprRecord = nlapiLoadRecord('customrecordvendorpricereview', vprRecordID);

//To set line items on this record use :
newVprRecord.selectNewLineItem(SUBLIST_Items);
...
//to set line item value use
newVprRecord.setCurrentLineItemValue(SUBLIST_Items,'custrecordvpri_costavg',  avgCost);
...
//to commit use 
newVprRecord.commitLineItem(SUBLIST_Items);
...
//finally after line items loop is done
nlapiSubmitRecord(newVprRecord,true);

这篇关于自定义记录/自定义子记录上的已提交子列表行未链接到主记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆