Hi,
I have a written a class where upon terminating an employee, the date has to be updated in own table(CaeEmplTable)
public static void caeWorkerTerminationInsert(HcmWorker hcmworker)
{
CAEEmplTable caeEmplTable;
HcmEmployment hcmemployment;
hcmemployment = hcmemployment ::find(hcmworker.RecId);
ttsBegin;
caeEmplTable = caeEmplTable::find(hcmEmployment.Worker,true);
if(caeEmplTable.RecId)
{
caeEmplTable.Termination = HcmReasonCode::find(HcmEmploymentDetail::findByEmployment(hcmEmployment.RecId).TransitionReasonCode).Description;
caeEmplTable.update();
}
else
{
caeEmplTable.Termination = HcmReasonCode::find(HcmEmploymentDetail::findByEmployment(hcmEmployment.RecId).TransitionReasonCode).Description;
caeEmplTable.insert();
}
ttsCommit;
}
But now i had add an logic that on terminating an employee it has to check the legal entity of that particular employee and update the end date in caeempltable.
HcmEmployment and CaeEmplTable has to 2 rows for one worker.
It’s actually transfer of employee
public static void caeWorkerTerminationInsert(HcmWorker hcmworker)
{
CAEEmplTable caeEmplTable;
HcmEmployment hcmemployment;
hcmemployment = hcmemployment ::find(hcmworker.RecId);
hcmemployment = hcmemployment::findByWorkerLegalEntity(hcmworker.RecId,CompanyInfo::current());
ttsBegin;
while select caeEmplTable
where caeEmplTable.dataAreaId == CompanyInfo::findByDataAreaID(CompanyInfo::current()).dataAreaId && caeEmplTable.Worker == hcmEmployment.Worker
if(caeEmplTable.RecId)
{
caeEmplTable.Termination = HcmReasonCode::find(HcmEmploymentDetail::findByEmployment(hcmEmployment.RecId).TransitionReasonCode).Description;
caeEmplTable.update();
}
else
{
caeEmplTable.Termination = HcmReasonCode::find(HcmEmploymentDetail::findByEmployment(hcmEmployment.RecId).TransitionReasonCode).Description;
caeEmplTable.insert();
}
ttsCommit;
}
from one company to another company. . So the value exists twice with different startdate and End date in both the company.
The above code of the employee exists only in one company but if its multiple company ,then the enddate gets update for both the company. it has to update only for selected company select eid…
hcmemployment = hcmemployment::findByWorkerLegalEntity(hcmworker.RecId,CompanyInfo::current());
while select caeEmplTable
where caeEmplTable.dataAreaId == CompanyInfo::findByDataAreaID(CompanyInfo::current()).dataAreaId && caeEmplTable.Worker == hcmEmployment.Worker
I wrote the above code to get the hcmemployment and caeempltable by legal entity wise. But when i debug it shows null
Thanks,