Hello everyone,
I'm having a problem with getting the employment details of past workers in the current company when I join hcmworker table to hcmEmployment table.
I'm using this job:
static void Job37(Args _args)
{
HcmWOrker hcmWorker;
HcmEmployment hcmEmployment;
DIrPersonName dirPersonName;
CompanyInfo companyInfo;
companyInfo = CompanyInfo::find(companyInfo::current());
info("Company :"+companyInfo.DataArea);
while select * from hcmWOrker order by hcmWOrker.PersonnelNumber
join dirPersonName where hcmWorker.Person==dirPersonName.Person
join hcmEmployment where hcmEmployment.Worker==hcmWorker.RecId
&& hcmEmployment.LegalEntity==companyInfo.RecId
{
info("Number: "+ hcmWorker.PersonnelNumber+" , Name: "+dirPersonName.LastName+" "+dirPersonName.FirstName);
}
}
and this is what I get in output:

As you can see, I can have the list of active workers (their numbers start with 020) in the same company (020).
The problem is that I can only get the workers that have a valid effective date due to a property called ValidTimeStateEnabled that is set to UtcDateTime in the hcmEmployment Table.This property limits the list of workers in terms of validfrom and validto date. I can't set it to None because it will delete all the records.
I need to get all employment details of the active and past workers in the same company.
Any Idea please?? Thank you for help.