Monday, September 24, 2018

How to change Company of Employee in Axapta by code

ttsBegin;  
     hcmWorker=hcmWorker::findByPersonnelNumber(Personalumberid);  
     select companyinfohsd where companyinfohsd.dataAreaId=="dat";  
     select companyinforss where companyinforss.dataAreaId=="ceu";  
     select forupdate hcmEmployment where hcmEmployment.Worker==hcmWorker.RecId && hcmEmployment.LegalEntity==companyinfohsd.RecId;  
     hcmEmployment.LegalEntity=companyinforss.RecId;  
     hcmEmployment.validTimeStateUpdateMode(ValidTimeStateUpdate::Correction);  
     hcmEmployment.doUpdate();  
     ttsCommit;  

No comments:

Post a Comment