Hi guys... Whats the best way to find the employee...
# suitescript
e
Hi guys... Whats the best way to find the employees with no transactions?
j
Copy code
var employeeSearchObj = search.create({
   type: "employee",
   filters:
   [
   ],
   columns:
   [
      search.createColumn({
         name: "entityid",
         summary: "GROUP",
         sort: search.Sort.ASC,
         label: "Name"
      }),
      search.createColumn({
         name: "internalid",
         join: "transaction",
         summary: "COUNT",
         label: "Internal ID"
      })
   ]
});
var searchResultCount = employeeSearchObj.runPaged().count;
log.debug("employeeSearchObj result count",searchResultCount);
employeeSearchObj.run().each(function(result){
   // Check if Employee Has Zero Transactions
   if(result.getValue({
         name: "internalid",
         join: "transaction",
         summary: "COUNT"
      }) === 0){
//Do something
}
   return true;
});
Not sure if best, but off the top of my head.
m
You could add a filter of
["count(transaction.internalid)", "equalto", "0"]
and only return employees with no transaction rather than returning all employees and filtering out those with transactions.
👍 1
e
thanks @jarens and @Mike Robbins