Saved Search to Show the First Item Receipt Date per Item

Jira Code : BGGN-615

Solution

/* Function to show the first item receipt date per item using the saved search **/
function showFirstIRCreatedDate()
{
var itemSearchObj = search.create({
   type: "item",
   filters:
   [
      ["type","anyof","OthCharge","Description","Discount","InvtPart","Group","Kit","Markup","NonInvtPart","Payment","Service","Subtotal"], 
      "AND", 
      ["transaction.type","anyof","ItemRcpt"]
   ],
   columns:
   [
      search.createColumn({
         name: "itemid",
         summary: "GROUP",
         sort: search.Sort.ASC,
         label: "Name"
      }),
      search.createColumn({
         name: "trandate",
         join: "transaction",
         summary: "MIN",
         label: "First IR Created Date"
      }),
      search.createColumn({
         name: "type",
         summary: "GROUP",
         label: "Type"
      })
   ]
});
var searchResultCount = itemSearchObj.runPaged().count;
log.debug("itemSearchObj result count",searchResultCount);
itemSearchObj.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 *