function timesheetSearch(project_Search_Result) {
try{
var filterArr = [];
if(project_Search_Result.length>0){
for(var i=0;i<project_Search_Result.length;i++){
filterArr.push(project_Search_Result[i].prjId)
}
}
var timesheetSearchObj = search.create({
type: "timesheet",
filters:
[
["custrecord_jj_supervisor_approval_status","anyof","1"],
"AND",
["totalhours","greaterthan","0.0"],
"AND",
["timesheetdate","onorafter","1/1/2020"],
"AND",
["timebill.customer","anyof",filterArr]
],
columns:
[
search.createColumn({
name: "internalid",
summary: "GROUP",
label: "Internal ID"
}),
search.createColumn({
name: "employee",
summary: "GROUP",
label: "Employee"
}),
search.createColumn({
name: "custrecord_jj_supervisor_approval_status",
summary: "GROUP",
label: "Supervisor Approval Status"
}),
search.createColumn({
name: "startdate",
summary: "GROUP",
label: "Start Date"
})
]
});
var res = []
timesheetSearchObj.run().each(function(result){
// .run().each has a limit of 4,000 results
var timesheetId = result.getValue({
name: "internalid",
summary: "GROUP"
})
var employee = result.getValue({
name: "employee",
summary: "GROUP"
})
var employeeTxt = result.getText({
name: "employee",
summary: "GROUP"
})
var startDate = result.getValue({
name: "startdate",
summary: "GROUP"
})
var client = result.getValue({
name: "customer",
join: "timeBill",
summary: "GROUP"
})
res.push({
timesheetId: timesheetId,
employee: employee,
employeeTxt: employeeTxt,
startDate: startDate,
client: client
})
return true;
});
return res
}
catch (e) {
log.error({
title: "Error @ Timesheet Search: ",
details: e.name+" : "+e.message
})
}
}