2016-12-22 1 views
0

하위 목록이있는 레코드가 있으며 해당 하위 목록의 모든 항목이 다른 하위 목록이있는 레코드입니다. 내가 원하는 것은 모든 itemA에 대해 모든 itemA 하위 목록의 모든 하위 목록을 가져 오는 것입니다. 이netsuite 스크립트 최적화

Bill of lading1 
    ->FulfillmentA 
     ->Item123 
     ->Item124 
     ->Item125 
    ->FulfillmentB 
     ->Item224 
     ->Item226 
     ->Item227 

처럼 나는이 개 이행은있다 선하 증권의 1 빌에 대한 예를 들어

Fulfillment | Item | Description | Qty 

선하

의 모든 빌이 같은 테이블을 생성 할 수 있도록하려면 그 이행은 각각 3가 나는이 작업을 수행 할 수있는 항목

   BILL OF LADING #4 
Fulfillment | Item | Description | Qty 
------------------------------------------- 
    A  | 123 |  xxxx | 2 
      | 124 |  xxxx | 1 
      | 125 |  xxxx | 7 
-------------------------------------------- 
    B  | 224 |  xxxx | 1 
      | 226 |  xxxx | 1 
      | 227 |  xxxx | 1 

는, 문제는 일부 fullfilment이 60 ~ 70 개 이행은 같이있을 때, 그때는 스크립트 실행 사용 한도 초과 오류가 제공됩니다.

* { 
    * 70: { 
    *  itemNumber : { 
    *  description: xxxx, 
    *  quantity: XX 
    *  }, 
    *  itemNumber2 : { 
    *  description: xxxx, 
    *  quantity: XX 
    *  }, 
    * 71: { ...}, 
    * .... 
    * } 

그런 다음 루프로 테이블을 만들 :

내 코드와 기본적인 아이디어는이 같은 개체를 만드는 것입니다.

var lines = record.getLineItemCount('recmachcustrecord_id_billoflading'); 
//Grab the fulfillment internal id 
for(var i = 1; i <= lines; i++){ 
    fullfillmentInternalIDArray.push(record.getLineItemValue('recmachcustrecord_id_billoflading', 'custrecord_fulfillment', i)); 
} 

//Get the fulfillment number 
for(var x = 1; x <= lines; x++){ 
    fulfillmentNumberArray.push(record.getLineItemText('recmachcustrecord_id_billoflading', 'custrecord_fulfillment', x).replace(/Fulfillment|#|Item/g,"")); 
} 

//Get the fulfillments and push them into an array 
//And create an empty object with the fulfillment number 
for(var z = 0; z < fullfillmentInternalIDArray.length; z++){ 
    fulfillmentArray.push(nlapiLoadRecord('itemFulfillment', fullfillmentInternalIDArray[z])); 
    billOfLadingFulfillmentsObject[ fulfillmentNumberArray[z] ] = {}; 
} 

: 나는 여기

작동 100 fullfilments이있는 BOL에 제거 할 때 내 코드는

fulfillmentArray.push(nlapiLoadRecord('itemFulfillment', fullfillmentInternalIDArray[z])); 

때문에 :

내가 생각하는 문제는이 라인이다 그런 다음 나머지 객체를 만듭니다.

for(var j = 0; j < fulfillmentArray.length; j++){ 
    itemCount = fulfillmentArray[j].getLineItemCount('item'); 

    for(var y = 1; y <= itemCount; y++){ 
     billOfLadingFulfillmentsObject[ fulfillmentNumberArray[j] ][ fulfillmentArray[j].getLineItemValue('item', 'itemname', y) ] = {}; 
    } 

    for(var item in billOfLadingFulfillmentsObject){ 
     for(var item2 in billOfLadingFulfillmentsObject[item]){ 
      for(var y = 1; y <= itemCount; y++){ 
       if(item2 === fulfillmentArray[j].getLineItemValue('item', 'itemname', y)){ 
        billOfLadingFulfillmentsObject[ fulfillmentNumberArray[j] ][item2]['description'] = fulfillmentArray[j].getLineItemValue('item', 'itemdescription', y); 
        billOfLadingFulfillmentsObject[ fulfillmentNumberArray[j] ][item2]['quantity'] = fulfillmentArray[j].getLineItemValue('item', 'quantity', y); 
       } 
      } 
     } 
    } 
} 

많은 이행이있을 때 스크립트 실행 사용 제한 초과 오류가 발생하지 않도록 최적화하는 방법을 모릅니다.

답변

0

저렴하기 때문에 대량의 데이터를 검색하기 위해 검색하는 것이 좋습니다. 항목 ID를 수집하는 항목을 반복하고 검색을 수행하여 데이터를 가져옵니다.