Alfasith AX

Alfasith AX
اللَّهُمَّ انْفَعْنِي بِمَا عَلَّمْتَنِي، وَعَلِّمْنِي مَا يَنْفَعُنِي، وَزِدْنِي عِلْمًا

Sunday, June 1, 2014

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(HrmImportEmployeeMasterdata::convDate(conpeek(_c, BirthDate)));
            hcmWorkerImport_HcmPersonPrivateDetails.parmGender(HrmImportEmployeeMasterdata::convGender(conpeek(_c, Gender)));
            //Address pf the worker related information...
            hcmWorkerImport_DirPartyPostalAddressVie = hcmWorkerImport_DirPerson_DirPerson.createDirPartyPostalAddressView().addNew();
            hcmWorkerImport_DirPartyPostalAddressVie.parmCountryRegionId(HrmImportEmployeeMasterdata::defaultCountryRegionId());
            hcmWorkerImport_DirPartyPostalAddressVie.parmRoles(HrmImportEmployeeMasterdata::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,

Basic table information in Dynamic AX

Hi,

Table name Information
HcmWorker Employee information
CustTable Customer information
PurchTable Purchase related information
EcoresProduct  Product information
InventTable Item information (released products)
SalesTable Sales information
VendTable  Vendor information
ProjTable Project information
Retail* All the retail related information table starts with retail as prefix
UserInfo User information
All the above tables are master table so the bears lines table / multiple lines tables

Regards,

How find size of recordsortedlist in D365/AX 2012

Hi, This is the continuity of the previous article where we are now getting the size of recordsortedlist . if(recordsortedlist.len() >1) ...