i created customized report and this is the process report logic the problem here is that i get the department for the current workers only i want to get also for the past worker
public void processReport()
{
RecId recid;
UserInfo userinfo;
DirPerson dirPerson;
DirPersonUser dirPersonUser;
SysUserLog sysUserLog;
HcmWorker hcmworker;
HcmPositionWorkerAssignment workerAssignment;
HcmPosition hcmPosition;
HcmPositionDetail hcmPositionDetail;
IsUserActiveContract Contract;
Contract =this.parmDataContract();
ttsBegin;
while select * from userinfo
outer join dirPersonUser
where dirPersonUser.User == userinfo.id
outer join dirPerson
where DirPersonUser.PersonParty == DirPerson.RecId
outer join hcmworker
where HcmWorker.Person == DirPerson.RecId
outer join worker, position from workerAssignment
where workerAssignment.Worker == hcmWorker.RecId
outer join recid from hcmPosition
where hcmPosition.RecId == workerAssignment.Position
outer join hcmPositionDetail
where HcmPositionDetail.Position == HcmPosition.RecId
{
TempTB.clear();
TempTB.Name = DirPerson.Name;
TempTB.IsEnabled = enum2str( userinfo.enable);
TempTB.UserID = dirPersonUser.User;
recId = HcmWorker::userId2Worker(TempTB.UserID);
TempTB.Title = hcmworker.title();
TempTB.UserID = userinfo.id;
select firstonly createdDateTime from sysUserLog order by createdDateTime desc where sysUserLog.UserId == TempTB.UserID;
TempTB.LastLogon = sysUserLog.createdDateTime;
TempTB.Department = HcmWorker::getDepartments(recId).Name;
TempTB.insert();
}
ttsCommit;
}