下面的代码是保存记录到Netsuite,我想选择行项目。我不想保存记录

时间:2017-04-05 11:04:25

标签: netsuite suitescript

下面的代码是选择存款的订单项。它将记录保存到Net suite.But我只想选择行项目,但没有发生。

function OnPageInit() 
    { 

      var search = nlapiSearchRecord(null, 'customsearch322'); 
      nlapiLogExecution('DEBUG', 'creating a `enter code here`deposit');
      var d = nlapiCreateRecord('depo' + 'sit');  

        d.setFieldValue('department', 13);
      d.setFieldValue('trandate', nlapiDateToString(new Date()));   
      d.setFieldValue('memo', 'created in code');

      d.selectNewLineItem('other');
      d.setCurrentLineItemValue('other','entity', 41877);
    d.setCurrentLineItemValue('other','department', 13);
    d.setCurrentLineItemValue('other','account', 135);
    d.setCurrentLineItemValue('other','amount',23);
    d.setCurrentLineItemValue('other','memo','Tgh');
    d.commitLineItem('other');
    // iF uncomment tbelow line it save records to Netsuite
      //var id = nlapiSubmitRecord(d, true);


    } 

2 个答案:

答案 0 :(得分:0)

以下是正确的代码

nlapiSelectLineItem("other", 1);
        nlapiSetCurrentLineItemValue('other','entity', 41877);
        nlapiSetCurrentLineItemValue('other','department', 13);
        nlapiSetCurrentLineItemValue('other','account', 135);
        nlapiSetCurrentLineItemValue('other','amount', 23);
        nlapiSetCurrentLineItemValue('other','memo','Tgh');
        nlapiCommitLineItem("other");

答案 1 :(得分:0)

这是工作代码...........

function clickMe() 
    { 

               var transid = nlapiGetFieldValue('custbody2');    
              var filters = [
                new nlobjSearchFilter('transactionnumber', null, 'is', transid), 
            ];
              var search = nlapiSearchRecord(null, 'customsearch322',filters); 
             var k=1;
            for(i=0;i<search.length;i++)
            {
                    var CheckaccountId=search[i]["valuesByKey"]["account"]["value"];
                    var ccode=search[i]["valuesByKey"]["customer_custentity_mb_ccode"]["value"];
                    var department=search[i]["valuesByKey"]["department"]["value"];
                    if(CheckaccountId =="1" || CheckaccountId=="7")
                    {           
                        var setaccount= getaccountforitem(CheckaccountId,ccode,department);                 
                        nlapiSelectLineItem("other", k);
                        k++;
                        var client =search[i]["valuesByKey"]["customer_internalid"]["value"];
                        nlapiSetCurrentLineItemValue('other','entity',client);
                        nlapiSetCurrentLineItemValue('other','department',search[i]["valuesByKey"]["department"]["value"]);
                        nlapiSetCurrentLineItemValue('other','account', setaccount);
                        nlapiSetCurrentLineItemValue('other','amount', search[i]["valuesByKey"]["amount"]["value"]);
                        //nlapiSetCurrentLineItemValue('other','class', search[i]["valuesByKey"]["classnohierarchy"]["value"]);
                        nlapiSetCurrentLineItemValue('other','memo',search[i]["valuesByKey"]["memo"]["value"]);
                        nlapiCommitLineItem("other");
                    }               
            }

    }