preloader-matrix

Alfasith

Job to creating Employee / or upload employee in Dynamic AX

Hi,

Use below code as method to your class that fetches the workbook and pass the values as container to the below method.

private void  EmployeeImportOrCreate(container _c)
{
HcmWorkerImportService                      hcmWorkerImportService;
HcmWorkerImport                             hcmWorkerImport;
HcmWorkerImport_HcmWorker                   hcmWorkerImport_HcmWorker;
HcmWorkerImport_DirPerson_DirPerson         hcmWorkerImport_DirPerson_DirPerson;
HcmWorkerImport_HcmPersonPrivateDetails     hcmWorkerImport_HcmPersonPrivateDetails;
HcmWorkerImport_DirPersonName               hcmWorkerImport_DirPersonName;
HcmWorkerImport_DirPartyPostalAddressVie    hcmWorkerImport_DirPartyPostalAddressVie;

HcmWorkerImport_HcmEmployment               hcmWorkerImport_HcmEmployment;
HcmWorkerImport_HcmEmploymentDetail         hcmWorkerImport_HcmEmploymentDetail;
HcmWorkerImport_HcmWorkerTitle              hcmWorkerImport_HcmWorkerTitle;
;
// Create EMP ID personnel Number …
hcmWorkerImportService          = HcmWorkerImportService::construct();
hcmWorkerImport                 = new HcmWorkerImport();
hcmWorkerImport_HcmWorker       = hcmWorkerImport.createHcmWorker().addNew();
hcmWorkerImport_HcmWorker.parmPersonnelNumber(conpeek(_c, EmployeeNumber));

hcmWorkerImport_DirPerson_DirPerson = hcmWorkerImport_HcmWorker.createDirPerson().addNew();
hcmWorkerImport_DirPerson_DirPerson.parmInitials(conpeek(_c, Initials));
hcmWorkerImport_DirPerson_DirPerson.parmProfessionalTitle(conpeek(_c, Position));
// For his name first / middle / last name…
hcmWorkerImport_DirPersonName       = hcmWorkerImport_DirPerson_DirPerson.createDirPersonName().addNew();
hcmWorkerImport_DirPersonName.parmFirstName(conpeek(_c, FirstName));
hcmWorkerImport_DirPersonName.parmMiddleName(conpeek(_c, MiddleName));
hcmWorkerImport_DirPersonName.parmLastName(conpeek(_c, LastName));
//For his Birth date and Gender…
hcmWorkerImport_HcmPersonPrivateDetails = hcmWorkerImport_DirPerson_DirPerson.createHcmPersonPrivateDetails().addNew();
hcmWorkerImport_HcmPersonPrivateDetails.parmBirthDate(HrmImportEmployee
Masterdata::convDate(conpeek(_c, BirthDate)));
hcmWorkerImport_HcmPersonPrivateDetails.parmGender(HrmImportEmployee
Masterdata::convGender(conpeek(_c, Gender)));
//Address pf the worker related information…
hcmWorkerImport_DirPartyPostalAddressVie = hcmWorkerImport_DirPerson_DirPerson.createDirPartyPostalAddressView().addNew();
hcmWorkerImport_DirPartyPostalAddressVie.parmCountryRegionId(HrmImport
Employee
Masterdata::defaultCountryRegionId());
hcmWorkerImport_DirPartyPostalAddressVie.parmRoles(HrmImportEmployee
Masterdata::defaultRole());
hcmWorkerImport_DirPartyPostalAddressVie.parmStreet(conpeek(_c, Address));
hcmWorkerImport_DirPartyPostalAddressVie.parmStreetNumber(conpeek(_c, streetnum)));
hcmWorkerImport_DirPartyPostalAddressVie.parmZipCode(conpeek(_c, PostalCode));
// Releasin to company address book but here this code add the cur3eest worker to current address book
hcmWorkerImport_HcmEmployment   = hcmWorkerImport_HcmWorker.createHcmEmployment().addNew();
hcmWorkerImport_HcmEmployment.parmLegalEntity(curext());

hcmWorkerImport_HcmEmploymentDetail = hcmWorkerImport_HcmEmployment.createHcmEmploymentDetail().addNew();
hcmWorkerImport_HcmEmploymentDetail.parmWorkerStartDate(
datetobeginUtcDateTime(
HrmImportEmployeeMasterdata::convDate(conpeek(_c, DateOfHiring)),
DateTimeUtil::getUserPreferredTimeZone()));
//Creation completion
hcmWorkerImportService.create(hcmWorkerImport);

}

Regards,

Share on email
Share on facebook
Share on twitter
Share on linkedin
Share on pinterest

Leave a Reply

Your email address will not be published.