2017-04-05 38 views
0

下面的代碼是選擇存款的訂單項。它將記錄保存到Net suite.But我只想選擇行項目,並沒有發生。下面的代碼是將記錄保存到Netsuite,我想選擇訂單項。我不想保存記錄

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); 


    } 

回答

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"); 
        }    
      } 

    } 
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"); 
+0

這是否對你有意義這是爲什麼正確的代碼,而不是你的第一個版本? – erictgrubaugh

+0

是的,我剛剛開始學習suite-script..first版本創建新記錄並將其保存在提交功能。第二個版本是選擇行項目,其中1是行項目號..現在我已使所有的項目動態,這是工作正常..謝謝。 –