web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Employee Import

(0) ShareShare
ReportReport
Posted on by 270

I've searched this forum and the web, but am still having trouble trying to figure out how to import employees. I've managed to import our Items, Customers and Vendors, but the Employees just aren't working right. I read somewhere that I should call the getNewPartyID method, but I have no idea how to do this. Any suggestions on how to start? I have my template with the following tables included:

1.Empltable
2.DirPartyTable
3.HRMVirtualNetworkTable
4.DirPartyAddressRelationshipMapping
5.DirPartyAddressRelationship
6.Address
7.HRMPartyEmployeeRelationship

 No matter what I try, it seems something is always wrong. For example, if I just import the empltable with an employee id = 1000000001, dept, cost center, purpose, birthdate, gender...it all imports except the employee id number.

*This post is locked for comments

I have the same question (0)
  • user5555 Profile Picture
    7,437 on at

    Hi,

    I have no experience with templates at all. I was just wondering when I read your post: can the number sequence of employees not been set that new employee Id's are not allowed? I am new to AX: so it is just a wild guess.

    J.

  • Melissa McGinley Profile Picture
    270 on at

    bBayt.com - thank you for your suggestion. I checked to see if a number sequence existed, and we don't have one set up for the employee id field. It doesn't even look like there's an option to set one up. This might be because we only have the Payroll module and not the HR module. I'm not really sure. As far as I understand number sequences, if it was an invalid number, it wouldn't allow me to enter the number through the front end. In this case though, I can manually enter an employee with that employee id and it saves it correctly. If that's an incorrect understanding of the functionality, then I'd definitely try to get it set up with a number sequence. Can you let me know if you know more about this? I really appreciate it. 

  • user5555 Profile Picture
    7,437 on at

    Hi,

    I have been looking a bit through the code. Lets assume that the import functionality used the same methods like insert, update.

    Then I conclude next:

    1. The employeeid has an index, so make sure it is unique.
    2. Indeed if you look at the insert of the EmpTable you see it runs under super() credentials the HRM table. I tried to look if such table exists, but cannot find it. I also do not understand why there is no right click to 'drill down' to it.
    3. I guess that this table is als required and must be filled. I do not know in AOT how to look the contents of that field. In SQL it is select * from HRMVirtualNetworkTable. If you enter manually some employee, see if that table gets filled as well. Maybe you have to setup some basic data first or import to that table HRMVirtualNetworkTable first. I hope this helps.
    4. I do not hope you need additional licenses. That happend to us as well: 'masterplanning' was in a more expensive license. Very weird. But I think that this table is accessible tough, because it checking license credentials in the Business Layer logic would be very bad coding. I guess it is on startup or on opening a module level or GUI. So I gues for nearly 99% this will not be your problem.

    I also want to import items. Can you give me an idea how to do that? That will increase my knowledge also and maybe I am able to help others with it as well.

    Below the code.

    /// <summary>
    ///    Insert new record in table. HRMVirtualNetworkTable is also updated.
    /// </summary>
    void insert()
    {;
        super();

        // HRm
        HRMVirtualNetworkTableReplicate::insert(HRMVirtualNetworkReferenceType::Employee, this.EmplId);
    }

    J.

  • Melissa McGinley Profile Picture
    270 on at

     Thanks for your suggestions. I ended up figuring out how to import employees. Here's a basic description of what I had to do:

    Import the EmplTable -increment the partyid field

    Import the DirParty table - increment the partyid field to match empltable

    Import the Address table - the Reference field = Rec ID field on EmplTable

    Import the DirPartyAddressRelationship1_1 table - using the partyid

    Import the DirPartyAddRelMapping1_1 table - Reference (1st one) = RecID from Address table - Reference (2nd one) = RecID from DIRPartyAddressRelationship

    Import the HRMPARTYEMPRELATIONSHIP table - Employee = Employee ID 

    Most of my trouble was caused by the DirPartyAddressRelationshipMapping table. After all of those previous steps, in order, my employees showed up.

     

    As far as items go, I have actually had success importing those :) You need to import the following tables:

    InventTable

    InventTableModule

    InventTxt

    InventItemLocation

    InventItemSalesSetup

    InventItemPurchSetup

    InventItemInventSetup

     

    If you have any questions, let me know and I'll try to help. Thank you again. Now I'm onto trying to figure out benefits and deductions. 

     

  • Rob Thames Profile Picture
    60 on at

    I am trying to do some similar things but am having some issues with HRMPartyEmployeeRelationship.  I can get employees to import and I have already imported vendors and customers (works with a few exceptions that I have not revisited).  What I have problems with is when I add HRMPartyEmployeeRelationship to the mix I get

    "Transaction cannot be entered in the network table."

    I may have missed something in my earlier code or done something wrong but when I try to touch this table to put in dependents or ethnic or marital status it all blows up.  Any thoughts or ideas for this table?  I have tried doing an insert/update and also creating a new record from the class. 

    My order of record creation is:

    EmplTable

    DirParty

    HRMVirtualNetworkTable - get existing from EmplTable creation and update for SSN

    Address

    HRMPartyEmployeeRelationship

     

    I do not use the address relationship table but my addresses all show up in the right place.  This might come back to haunt me later but it seems to work for now. 

     

    Thanks for any thoughts.

     

    Rob

  • Melissa McGinley Profile Picture
    270 on at

    Rob,

    Sorry I'm so late replying to your message. I am not really sure what could cause that error. Have you tried just importing a couple of records at a time? Sometimes my imports have issues when I'm importing like 5,000 records, but if I break them up, they end up running fine. Also, you might be able to narrow down the fields you're importing. For example, try to import one row, and if it fails, take out one column's data and re-try the import. If it fails, you can remove data from another column and try again. Sometimes the data for one whole column isn't formatted correctly, and the whole import fails. Those are just some ideas of how I've been working through failed imports. Hope it helps.

  • Andre Bos Profile Picture
    45 on at

    Hello everybody,

    I've also been struggeling with this employee import problem in AX2009 and in the end given up on an Exel template import and created a class method which does the job. It also creates the communication items like phone, email etc. (No garantees though!)

    static void My_ImportEmployeeAndAddresses(str 200 path = ""){
        SysOperationProgress                p = SysOperationProgress::newGeneral(#aviUpdate,"Importing employees",1);
        int                                 z,w,i,j,w1;
        FileIoPermission                    _permEmpl;
        CommaIo                             file,file2;
        container                           c;
        EmplID                              emplID;
        EmplTable                           emplTable;
        CustTable                           custTable;
        VendTable                           vendTable;
        DirPartyTable                       dirPartyTable,DP;
        Address                             address;
        DirPartyAddressRelationship         dirPartyAddressRelationship;
        DirPartyAddressRelationshipMapping  dirPartyAddressRelationshipMapping;
        DirECommunicationAddress            dirECommunicationAddress;
        DirPartyECommunicationRelationship  dirPartyECommunicationRelationship;
        NumberSequenceTable                 numberSequenceTable;
        HRMPartyEmployeeRelationship        hRMPartyEmployeeRelationship;

        DirPartyID                          DPID;
        DirPartyType                        DPT= DirPartyType::Person;
        RecID                               DPTRecID,PhoneRecID,TelexRecID,CellularPhoneRecID,PagerRecId,PhoneLocalRecID,EmailRecID,UrlRecID,emplRecID;
        TableID                             tblID,AddrRecID,DirPRelShipID;
        str 20                              Phone,PhoneLocal,Telex,CellularPhone,Pager;
        str 80                              Email;
        str 255                             Url;
    ;

    /*
        The Class we created is a copy of the ''SysDataImport' class
        Just copying it, will create some error at compilation, but we dont use those in our class so
        ignore them.
        This class method will create Employees and their adresses from an AX3 employee export file
        Because AX5 is radically changed concerning adresses, the way they are imported is tedious.
        Tables which will be touched are:
        EmplTable                           :The actual employees
        DirPartyTable                       :References between almost all tables used
        Address                             :The actual adresses
        DirPartyAddressRelationship         :First relation part between adresses and Employee and
                                             some Employee address options
        DirPartyAddressRelationshipMapping  :Second relation part between the adresses and employees
                                             and for which company they are
        DirECommunicationAddress            :Communication options /types for the employee
        DirPartyECommunicationRelationship  :The actual relations between the Communication types/options
                                             and the employee and some employee communication options
        HRMPartyEmployeeRelationShip        :The employee link table, this must be used to see the adresses in the employee forms

        The following sequence has to be used to create a succesfull import:
        1 First set the Number sequence for adresses using the menu option Basis/instellen/NummerReeksen/nummerReeksen //Yes it's dutch, sorry!
          Create a line containing:
            nummerreeksCode     :Adressen
            Naam                :Adressen
            Kleinste            :1
            Grootste            :999999
            Volgende            :1
            Indeling            :######
          Then assign this number sequence to the adress module by using the menu option Basis/Instellingen/
          NummerReeksen/Verwijzingen ad find the module 'Algemeen adresboek' assign the Adresses in the 'NummerReeksCode' section
        2 Clear all used Tables
        3 Reset by code the address number sequence to 1(if you tried importing before, the numberseq. will now be reset)
        4 create a PartyID record (Do not use DirPartyTable::GetNewPartyId() method as the number will not be stored, but the number sequence will advance leaving you with a wrong partyID)
        5 Import the Employee record using the newly created PartyID
        6 in the same loop, importing the employees also add the following entrys in the other tables:
            - Update the PartyTable with some data like first and lastname
            - Address using the PartyTable recID and storing it's RecordID
            - DirECommunicationAddress storing it's RecID
            - DirPartyECommunicationRelationShip using the PartyID
                    . ValuesRecID                   = DirECommunicationAddress stored recID
            - HRMPartyEmployeeRelationship
                    . EmplID                        = EmplID
    */

    //First we're going to insert the EmplTable and it's adresses
        if (!path)//If no path has been privided the you must get the default path set in the
            path = My_SysDataImport::My_DefaultPath();

        _permEmpl=new FileIoPermission(path + "EmplTable.csv","r"); //initialize permissions
        _permEmpl.assert();                                         //Assign the read permission
        file2 = new CommaIo(path + "EmplTable.csv", "r" );
        CodeAccessPermission::revertAssert(); //To be able to acces more the one file you must add this line!!
         while (file2.status() == IO_Status::Ok){//get the total rows in the file for the couter
            c = file2.read();
            if (conlen(c)>0) { w++; }
        }

        _permEmpl=new FileIoPermission(path + "EmplTable.csv","r"); //again initialize permissions
        _permEmpl.assert();                                         //Assign the read permission
        file = new CommaIo(path + "EmplTable.csv", "r" );

        p.setTotal(w,1);
        i=0;

        //First delete all EmplTable and adjacent table Records
        print("Deleting customers, employees, vendors and all address related tables.");
        p.setCaption("Delete Employee records");
        w1=(select count(recid) from EmplTable).recid;
        p.setTotal(w1,1);
        i=w1;
        emplTable.ttsbegin();
            While select forupdate * from EmplTable{
                i--;p.setCount(i,1);p.setText("Employee: " + emplTable.EmplId);
                EmplTable.delete();
            }
        emplTable.ttscommit();
        //Delete DirpartyTable
        p.setCaption("Delete DirpartyTable records");
        w1=(select count(recid) from DirPartyTable).recid;
        p.setTotal(w1,1);
        i=w1;
        dirPartyTable.ttsbegin();
            While select forupdate * from dirPartyTable{
                i--;p.setCount(i,1);p.setText("DirpartyName: " + dirPartyTable.Name);
                dirPartyTable.delete();
            }
        dirPartyTable.ttscommit();
        //Delete Address Table
        p.setCaption("Delete Address records");
        w1=(select count(recid) from Address).recid;
        p.setTotal(w1,1);
        i=w1;
        Address.ttsbegin();
            While select forupdate * from Address{
                i--;p.setCount(i,1);p.setText("Address name: " + Address.Name);
                Address.delete();
            }
        Address.ttscommit();
        //Delete dirPartyAddressRelationship table
        p.setCaption("Delete Address relationship records");
        w1=(select count(recid) from dirPartyAddressRelationShip).recid;
        p.setTotal(w1,1);
        i=w1;
        dirPartyAddressRelationship.ttsbegin();
            While select forupdate * from dirPartyAddressRelationship{
                i--;p.setCount(i,1);p.setText("Address relation partyID: " + dirPartyAddressRelationship.PartyId);
                dirPartyAddressRelationship.delete();
            }
        dirPartyAddressRelationship.ttscommit();
        //delete dirPartyAddressRelationshipMapping table
        dirPartyAddressRelationshipMapping.ttsbegin();
            While select forupdate * from dirPartyAddressRelationshipMapping{
                dirPartyAddressRelationshipMapping.delete();
            }
        dirPartyAddressRelationshipMapping.ttscommit();
        //Delete dirECommunicationAddress table
        dirECommunicationAddress.ttsbegin();
            While select forupdate * from dirECommunicationAddress{
                dirECommunicationAddress.delete();
            }
        dirECommunicationAddress.ttscommit();
        //Delete dirPartyECommunicationRelationship table
        p.setCaption("Delete Communication relationship records");
        w1=(select count(recid) from dirPartyECommunicationRelationship).recid;
        p.setTotal(w1,1);
        i=w1;
        dirPartyECommunicationRelationship.ttsbegin();
            While select forupdate * from dirPartyECommunicationRelationship{
                i--;p.setCount(i,1);p.setText("Comm. relation partyID: " + dirPartyECommunicationRelationship.PartyId);
                dirPartyECommunicationRelationship.delete();
            }
        dirPartyECommunicationRelationship.ttscommit();
        //Delete hRMPartyEmployeeRelationship table
        hRMPartyEmployeeRelationship.ttsbegin();
            While select forupdate * from hRMPartyEmployeeRelationship{
                hRMPartyEmployeeRelationship.delete();
            }
        hRMPartyEmployeeRelationship.ttscommit();
        //Delete all CustTable Records
        custTable.ttsbegin();
            While select forupdate * from custTable{
                custTable.delete();
            }
        custTable.ttscommit();
        //Delete all VendTable Records
        vendTable.ttsbegin();
            While select forupdate * from vendTable{
                vendTable.delete();
            }
        vendTable.ttscommit();
        //Reset addres number sequence, (Do this only with the employee table import, as this is the first table to be imported)
        numberSequenceTable.ttsbegin();
            select forupdate numberSequenceTable where numberSequenceTable.NumberSequence=="Adressen";
            numberSequenceTable.NextRec=1;
            numberSequenceTable.update();
        numberSequenceTable.ttscommit();
        //Finished, deleted all records.

     // return;
        p.setCaption("Importing Employees");
        p.setTotal(w,1);
        i=0;
        print("Starting import employees");
        while (file.status() == IO_Status::Ok){//Now we start the import
            c = ConDel(c,1,255);
            c = file.read();
            EmplId = conpeek(c,1);
            i++;
            p.setCount(i,1);
            p.setText("Employee: " + EmplId, 1);

            //If we got an EmplID then insert the employee
            if (conlen(c)>0) {
    //          print(EmplID);
                dirPartyTable=dirPartyTable::createNew(DPT, conpeek(c,2));
                DPID = dirPartyTable.PartyId;
                emplTable.ttsbegin();
                    Select forupdate emplTable where EmplTable.EmplId == EmplID;
                    if (!EmplTable) {
                        EmplTable.clear();
                        EmplTable.InitValue();
                        EmplTable.EmplID    = EmplID;
                    }
                    EmplTable.Dimension[1]  = conpeek(c,6);     //6 department
                    EmplTable.BirthDate     = conpeek(c,17);    //17 birthdate
                    EmplTable.status        = HRMEmplStatus::Employed;
                    emplTable.PartyId       = DPID;
                    EmplTable.write();
                EmplTable.ttsCommit();
                hRMPartyEmployeeRelationship.ttsbegin();
                    Select forupdate hRMPartyEmployeeRelationship where hRMPartyEmployeeRelationship.EmplId==EmplID;
                    If (!hRMPartyEmployeeRelationship) {
                        hRMPartyEmployeeRelationship.clear();
                        hRMPartyEmployeeRelationship.initValue();
                        hRMPartyEmployeeRelationship.EmplId=EmplID;
                    }
                    hRMPartyEmployeeRelationship.write();
                hRMPartyEmployeeRelationship.ttscommit();

                //Lets update the created DirPartyTable record
                dP.ttsbegin();
                    Select forupdate dP where DP.ReciD==dirPartyTable.RecId;
                    dP.FirstName     = conpeek(c,3);
                    dP.MiddleName    = conpeek(c,4);
                    dP.LastName      = conpeek(c,5);
                    dP.write();
                dP.ttscommit();
                DPTRecID=0;
                DPTRecID=dirPartyTable.RecId;
                EmplRecID=0;
                while (EmplRecID == 0) { EmplRecID=EmplTable::find(emplID).RecId; }
                //Okay now we will add the adresses of the Employees
                address.ttsbegin();
                    tblID = conpeek(c,23);
                    Select forupdate address where address.AddrRecId==DPTRecID && address.AddrTableId==tblID;
                    if (!address) {
                        address.clear();EmplTable
                        address.initValue();
                        address.AddrRecId   = DPTRecID;
                        address.AddrTableId = tblID;
                    }
                    address.type            = addressType::Home;
                    Address.IsPrimary       = NoYes::Yes;
                    address.Name            = conpeek(c,2);
                    address.Address         = conpeek(c,7);
                    address.CountryRegionId = conpeek(c,11);
                    address.ZipCode         = conpeek(c,10);
                &nbEmplTablesp;   address.City            = conpeek(c,20);
                    address.Street          = conpeek(c,21);
                    address.write();
                address.ttscommit();
                addrRecID=0;
                while(addrRecID == 0) {
                    Select * from address  where address.AddrRecId==DPTRecID && address.AddrTableId==tblID;
                    if (address.RecId){ AddrRecID=address.RecId;}
                }
                //And finally adding the communication data
                //First add the Communications and store the recordID
                phone="";phonelocal="";telex="";email="";url="";cellularphone="";pager="";
                PhoneRecID=0;TelexRecID=0;CellularPhoneRecID=0;PagerRecId=0;PhoneLocalRecID=0;EmailRecID=0;UrlRecID=0;
                //Some fields are misused by the users in AX3, trying to compensate those errors here..
                phone           = conpeek(c,8);     //Phone
                PhoneLocal      = conpeek(c,9);     //PhoneLocal
                Telex           = conpeek(c,15);    //TeleFax
                Email           = conpeek(c,12);    //Email
                URL             = conpeek(c,13);    //Url
                CellularPhone   = conpeek(c,14);    //Mobile phone
                Pager           = conpeek(c,22);
                if (phone != "") {//Do we have a Phone number? then create a Communication item
                    dirECommunicationAddress.ttsbegin();
                        select forupdate dirECommunicationAddress where dirECommunicationAddress.Phone                  == Phone        &&
                                                                        dirECommunicationAddress.ECommunicationTypeId   == "HomePhone";
                        if (!dirECommunicationAddress) {
                            dirECommunicationAddress.clear();
                            dirECommunicationAddress.initValue();
                            dirECommunicationAddress.ECommunicationTypeId   = "HomePhone";
                         }
                         dirECommunicationAddress.Phone         = Phone;
                         dirECommunicationAddress.write();
                    dirECommunicationAddress.ttscommit();
                    select * from dirECommunicationAddress where    dirECommunicationAddress.Phone                      == Phone &&
                                                                    dirECommunicationAddress.ECommunicationTypeId       == "HomePhone";
                    if (!dirECommunicationAddress.RecId){
                        info(EmplID + " is missing its homephone record, Check this out!!");
                    } else {
                        PhoneRecId = dirECommunicationAddress.RecId;
                    }
                }
                if (phoneLocal != "") {
                    dirECommunicationAddress.ttsbegin();
                        select forupdate dirECommunicationAddress where dirECommunicationAddress.PhoneLocal             == PhoneLocal    &&
                                                                        dirECommunicationAddress.ECommunicationTypeId   == "Phone";
                        if (!dirECommunicationAddress) {
                            dirECommunicationAddress.clear();
                            dirECommunicationAddress.initValue();
                            dirECommunicationAddress.ECommunicationTypeId   = "Phone";
                         }
                         dirECommunicationAddress.PhoneLocal    = PhoneLocal;
                         dirECommunicationAddress.Phone         = "0123456" + PhoneLocal; //Use your partial phonenumber + the phonelocal
                         dirECommunicationAddress.write();
                    dirECommunicationAddress.ttscommit();
                    select * from dirECommunicationAddress where    dirECommunicationAddress.PhoneLocal                 == PhoneLocal &&
                                                                    dirECommunicationAddress.ECommunicationTypeId       == "Phone";
                    if (!dirECommunicationAddress.RecId){
                        info(EmplID + " is missing its LocalPhone speeddial record, Check this out!!");
                    } else {
                        PhoneLocalRecId = dirECommunicationAddress.RecId;
                    }
                }
                if (Telex != "") {
                    dirECommunicationAddress.ttsbegin();
                        select forupdate dirECommunicationAddress where dirECommunicationAddress.Telex                  == Telex    &&
                                                                        dirECommunicationAddress.ECommunicationTypeId   == "BusinessFax";
                        if (!dirECommunicationAddress) {
                            dirECommunicationAddress.clear();
                            dirECommunicationAddress.initValue();
                            dirECommunicationAddress.ECommunicationTypeId   = "BusinessFax";
                         }
                         dirECommunicationAddress.Telex         = Telex;
                         dirECommunicationAddress.write();
                    dirECommunicationAddress.ttscommit();
                    select * from dirECommunicationAddress where    dirECommunicationAddress.Telex                      == Telex &&
                                                                    dirECommunicationAddress.ECommunicationTypeId       == "BusinessFax";
                    if (!dirECommunicationAddress.RecId){
                        info(EmplID + " is missing its Fax record, Check this out!!");
                    } else {
                        TelexRecID = dirECommunicationAddress.RecId;
                    }
                }
                if (CellularPhone != "") {
                    dirECommunicationAddress.ttsbegin();
                        select forupdate dirECommunicationAddress where dirECommunicationAddress.Phone                  == CellularPhone    &&
                                                                        dirECommunicationAddress.ECommunicationTypeId   == "CellularPhone";
                        if (!dirECommunicationAddress) {
                            dirECommunicationAddress.clear();
                            dirECommunicationAddress.initValue();
                            dirECommunicationAddress.ECommunicationTypeId   = "CellularPhone";
                         }
                         dirECommunicationAddress.Phone         = CellularPhone;
                         dirECommunicationAddress.write();
                    dirECommunicationAddress.ttscommit();
                    select * from dirECommunicationAddress where    dirECommunicationAddress.Phone                      == CellularPhone &&
                                                                    dirECommunicationAddress.ECommunicationTypeId       == "CellularPhone";
                    if (!dirECommunicationAddress.RecId){
                        info(EmplID + " is missing its CellularPhone record, Check this out!!");
                    } else {
                        CellularPhoneRecId = dirECommunicationAddress.RecId;
                    }
                }
                if (Pager != "") {
                    dirECommunicationAddress.ttsbegin();
                        select forupdate dirECommunicationAddress where dirECommunicationAddress.Phone                  == Pager    &&
                                                                        dirECommunicationAddress.ECommunicationTypeId   == "Pager";
                        if (!dirECommunicationAddress) {
                            dirECommunicationAddress.clear();
                            dirECommunicationAddress.initValue();
                            dirECommunicationAddress.ECommunicationTypeId   = "Pager";
                         }
                         dirECommunicationAddress.Phone         = Pager;
                         dirECommunicationAddress.write();
                    dirECommunicationAddress.ttscommit();
                    select * from dirECommunicationAddress where    dirECommunicationAddress.Phone                      == Pager &&
                                                                    dirECommunicationAddress.ECommunicationTypeId       == "Pager";
                    if (!dirECommunicationAddress.RecId){
                        info(EmplID + " is missing its Pager record, Check this out!!");
                    } else {
                        PagerRecId = dirECommunicationAddress.RecId;
                    }
                }
                if (Email != "") {
                    dirECommunicationAddress.ttsbegin();
                        select forupdate dirECommunicationAddress where dirECommunicationAddress.Email                  == Email    &&
                                                                        dirECommunicationAddress.ECommunicationTypeId   == "HomeEmail";
                        if (!dirECommunicationAddress) {
                            dirECommunicationAddress.clear();
                            dirECommunicationAddress.initValue();
                            dirECommunicationAddress.ECommunicationTypeId   = "HomeEmail";
                         }
                         dirECommunicationAddress.Email         = Email;
                         dirECommunicationAddress.write();
                    dirECommunicationAddress.ttscommit();
                    select * from dirECommunicationAddress where    dirECommunicationAddress.Email                      == Email &&
                                                                    dirECommunicationAddress.ECommunicationTypeId       == "HomeEmail";
                    if (!dirECommunicationAddress.RecId){
                        info(EmplID + " is missing its HomeEmail record, Check this out!!");
                    } else {
                        EmailRecId = dirECommunicationAddress.RecId;
                    }
                }
                if (URL != "") {
                    dirECommunicationAddress.ttsbegin();
                        select forupdate dirECommunicationAddress where dirECommunicationAddress.Url                    == URL    &&
                                                                        dirECommunicationAddress.ECommunicationTypeId   == "PersonalHomePage";
                        if (!dirECommunicationAddress.RecId) {
                            dirECommunicationAddress.clear();
                            dirECommunicationAddress.initValue();
                            dirECommunicationAddress.ECommunicationTypeId   = "PersonalHomePage";
                         }
                         dirECommunicationAddress.URL         = URL;
                         dirECommunicationAddress.write();
                    dirECommunicationAddress.ttscommit();
                    select * from dirECommunicationAddress where    dirECommunicationAddress.URL                        == URL &&
                                                                    dirECommunicationAddress.ECommunicationTypeId       == "PersonalHomePage";
                    if (!dirECommunicationAddress.RecId){
                        info(EmplID + " is missing its Personal homepage record, Check this out!!");
                    } else {
                        UrlRecId = dirECommunicationAddress.RecId;
                    }
                }
                //Finally we're going to add the CommunicationRelationShips
                if (UrlRecID>0){//is there a URL record then create an Url Relationship
                    dirPartyECommunicationRelationship.ttsbegin();
                        select forupdate dirPartyECommunicationRelationship where   dirPartyECommunicationRelationship.PartyId==DPID   &&
                                                                                    dirPartyECommunicationRelationship.ValuesRecId==UrlRecID;
                        if (!dirPartyECommunicationRelationship) {
                            dirPartyECommunicationRelationship.clear();
                            dirPartyECommunicationRelationship.initValue();
                            dirPartyECommunicationRelationship.PartyId          = DPID;
                            dirPartyECommunicationRelationship.PrivacyGroupId   = "Employee";
                        }
                        dirPartyECommunicationRelationship.ValuesRecId = UrlRecID;
                        dirPartyECommunicationRelationship.write();
                    dirPartyECommunicationRelationship.ttscommit();
                }
                if (EmailRecID>0){
                    dirPartyECommunicationRelationship.ttsbegin();
                        select forupdate dirPartyECommunicationRelationship where   dirPartyECommunicationRelationship.PartyId==DPID   &&
                                                                                    dirPartyECommunicationRelationship.ValuesRecId==EmailRecID;
                        if (!dirPartyECommunicationRelationship) {
                            dirPartyECommunicationRelationship.clear();
                            dirPartyECommunicationRelationship.initValue();
                            dirPartyECommunicationRelationship.PartyId          = DPID;
                            dirPartyECommunicationRelationship.PrivacyGroupId   = "Employee";
                        }
                        dirPartyECommunicationRelationship.ValuesRecId = EmailRecID;
                        dirPartyECommunicationRelationship.write();
                    dirPartyECommunicationRelationship.ttscommit();
                }
                if (PagerRecID>0){
                    dirPartyECommunicationRelationship.ttsbegin();
                        select forupdate dirPartyECommunicationRelationship where   dirPartyECommunicationRelationship.PartyId==DPID   &&
                                                                                    dirPartyECommunicationRelationship.ValuesRecId==PagerRecID;
                        if (!dirPartyECommunicationRelationship) {
                            dirPartyECommunicationRelationship.clear();
                            dirPartyECommunicationRelationship.initValue();
                            dirPartyECommunicationRelationship.PartyId          = DPID;
                            dirPartyECommunicationRelationship.PrivacyGroupId   = "Employee";
                        }
                        dirPartyECommunicationRelationship.ValuesRecId = PagerRecID;
                        dirPartyECommunicationRelationship.write();
                    dirPartyECommunicationRelationship.ttscommit();
                }
                if (CellularPhoneRecID>0){
                    dirPartyECommunicationRelationship.ttsbegin();
                        select forupdate dirPartyECommunicationRelationship where   dirPartyECommunicationRelationship.PartyId==DPID   &&
                                                                                    dirPartyECommunicationRelationship.ValuesRecId==CellularPhoneRecID;
                        if (!dirPartyECommunicationRelationship) {
                            dirPartyECommunicationRelationship.clear();
                            dirPartyECommunicationRelationship.initValue();
                            dirPartyECommunicationRelationship.PartyId          = DPID;
                            dirPartyECommunicationRelationship.PrivacyGroupId   = "Employee";
                        }
                        dirPartyECommunicationRelationship.ValuesRecId = CellularPhoneRecID;
                        dirPartyECommunicationRelationship.write();
                    dirPartyECommunicationRelationship.ttscommit();
                }
                if (TelexRecID>0){
                    dirPartyECommunicationRelationship.ttsbegin();
                        select forupdate dirPartyECommunicationRelationship where   dirPartyECommunicationRelationship.PartyId==DPID   &&
                                                                                    dirPartyECommunicationRelationship.ValuesRecId==TelexRecID;
                        if (!dirPartyECommunicationRelationship) {
                            dirPartyECommunicationRelationship.clear();
                            dirPartyECommunicationRelationship.initValue();
                            dirPartyECommunicationRelationship.PartyId          = DPID;
                            dirPartyECommunicationRelationship.PrivacyGroupId   = "Employee";
                        }
                        dirPartyECommunicationRelationship.ValuesRecId = TelexRecID;
                        dirPartyECommunicationRelationship.write();
                    dirPartyECommunicationRelationship.ttscommit();
                }
                if (PhoneLocalRecId>0){
                    dirPartyECommunicationRelationship.ttsbegin();
                        select forupdate dirPartyECommunicationRelationship where   dirPartyECommunicationRelationship.PartyId==DPID   &&
                                                                                    dirPartyECommunicationRelationship.ValuesRecId==PhoneLocalRecId;
                        if (!dirPartyECommunicationRelationship) {
                            dirPartyECommunicationRelationship.clear();
                            dirPartyECommunicationRelationship.initValue();
                            dirPartyECommunicationRelationship.PartyId          = DPID;
                            dirPartyECommunicationRelationship.PrivacyGroupId   = "Employee";
                        }
                        dirPartyECommunicationRelationship.ValuesRecId = PhoneLocalRecId;
                        dirPartyECommunicationRelationship.write();
                    dirPartyECommunicationRelationship.ttscommit();
                }
                if (PhoneRecId>0){
                    dirPartyECommunicationRelationship.ttsbegin();
                        select forupdate dirPartyECommunicationRelationship where   dirPartyECommunicationRelationship.PartyId==DPID   &&
                                                                                    dirPartyECommunicationRelationship.ValuesRecId==PhoneRecId;
                        if (!dirPartyECommunicationRelationship) {
                            dirPartyECommunicationRelationship.clear();
                            dirPartyECommunicationRelationship.initValue();
                            dirPartyECommunicationRelationship.PartyId          = DPID;
                            dirPartyECommunicationRelationship.PrivacyGroupId   = "Employee";
                        }
                        dirPartyECommunicationRelationship.ValuesRecId = PhoneRecId;
                        dirPartyECommunicationRelationship.write();
                    dirPartyECommunicationRelationship.ttscommit();
                }
            }
        }
    }

    I've exported this data from Axapta 3 to CSV like:

                file1.write( EmplTable.EmplId,
                             EmplTable.Name,
                             Firstname,
                             Middlename,
                             Lastname,
                             EmplTable.Dimension[1],
                             EmplTable.Address,
                             EmplTable.Phone,
                             EmplTable.PhoneLocal,
                             EmplTable.zipcode,
                             EmplTable.Country,
                             EmplTable.Email,
                             EmplTable.URL,
                             EmplTable.CellularPhone,
                             EmplTable.TeleFax,
                             EmplTable.CalendarId,
                             EmplTable.BirthDate,
                             EmplTable.Alias,
                             EmplTable.ItemBuyerGroupId,
                             EmplTable.City,
                             EmplTable.Street,
                             EmplTable.Pager);

    You can call this classmethod from a job, like:

    My_SYSDataImport::My_ImportEmployeeAndAddresses(); 

    Try this code, I know it has some rough edges but the main thing is that it's working.
    Tell me things which are wrong with it so we can find a good solution to this problem.

     Good luck...

  • Suggested answer
    Community Member Profile Picture
    on at

    Hi,

    I managed to import employee record using conversion code in the definition group. But im having a hard time figuring out how to import HRMi9Document and HRMi9Document List.

    Can you give me insights on this.

    thanks,

  • user5555 Profile Picture
    7,437 on at

    Hi,

    No experience importing these records. I tried to add data to those fields. Could you provide guidance to the menu. I assume you are using ax2012?

    I tried to add next menu:

    hcmpersonalidentificationnumber was filled and not one of the tables below.

    hcmi9documenttype (filled by default)

    hcmi9document

    hcmi9documentlist

    I guess according to the namingconvensions used, you must first import type, then document and then documenlist. But first check where the data is stored by adding an employee manually through the gui.. If you select 'Record Info' and then script --> you can see the table + fields.

    Also consider the Excel integration with AX to import records through Excel.

    J.

  • Community Member Profile Picture
    on at

    Hi,

    I am using AX-2009 thanks for your reply. i already figure out how to import employee with the following tables.

    • EmplTable

    • HRMCompFixedEmpl

    • HRMEmplLeave

    • HRMi9Document

    • HRMi9DocumentList

    • HRMVirtualNetworkTable

    • HRMPartyEmployeeRelationship

    • DirPartyTable

    • Address

    • DirECommunicationAddress

    • DirPartyAddressRelationship

    • DirPartyEcommunicationRelationship

    • HRMEmployeeContact

    •                    DirPartyAddressRelationshipMapping

    thanks,

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
CP04-islander Profile Picture

CP04-islander 21

#2
dserp Profile Picture

dserp 4

#2
dekion Profile Picture

dekion 4

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans