Banket Purchase order and Purchase order Line Mapping Search

Within the Purchase Order record, there is currently no feature available to directly link and identify the corresponding item line within the Blanket Purchase Order. To address this, we can use a search method to determine the corresponding line number in the Blanket Purchase Order.

In this particular search, the “Applied to Transaction Line ID” will serve as the identifier for the Blanket Purchase Order Line associated with the Purchase Order Line ID.

var purchaseorderSearchObj = search.create({
   type: "purchaseorder",
   filters:
   [
      ["type","anyof","PurchOrd"],
      "AND",
      ["taxline","is","F"],
      "AND",
      ["cogs","is","F"],
      "AND",
      ["shipping","is","F"],
      "AND",
      ["internalid","anyof",{PO internla Id}],
      "AND", 
      ["appliedtotransaction.type","anyof","BlankOrd"]
   ],
   columns:
   [
      search.createColumn({name: "tranid", label: "Document Number"}),
      search.createColumn({name: "item", label: "Item"}),
      search.createColumn({name: "line", label: "Line ID"}),
      search.createColumn({
         name: "line",
         join: "createdFrom",
         label: "Line ID"
      }),
      search.createColumn({name: "createdfrom", label: "Created From"}),
      search.createColumn({name: "appliedtotransaction", label: "Applied To Transaction"}),
      search.createColumn({
         name: "item",
         join: "appliedToTransaction",
         label: "Item"
      }),
      search.createColumn({
         name: "line",
         join: "appliedToTransaction",
         label: "Line ID"
      })
   ]
});
var searchResultCount = purchaseorderSearchObj.runPaged().count;
log.debug("purchaseorderSearchObj result count",searchResultCount);
purchaseorderSearchObj.run().each(function(result){
   // .run().each has a limit of 4,000 results
   return true;
});

Leave a comment

Your email address will not be published. Required fields are marked *