Hi All,
Today we will be having a look at the AIFDocumentServices to create Worker (Contractor/Employee) into AX 2012 using HcmWorkerImportService.
Pre-requisites:
1) AX 2012 with CU2
2) Demo Data
3) Visual Studio Dev Tools
Scenario:
Wants to create/import worker into AX 2012 from an external application.
Solution:
Today we will be having a look at the AIFDocumentServices to create Worker (Contractor/Employee) into AX 2012 using HcmWorkerImportService.
Pre-requisites:
1) AX 2012 with CU2
2) Demo Data
3) Visual Studio Dev Tools
Scenario:
Wants to create/import worker into AX 2012 from an external application.
Solution:
- Create a Service Group in AOT
- Rename it to HcmWorkerImportDemo
- Drag the "HcmWorkerImportService" into your newly created service group.
- Right Click on the "HcmWorkerImportDemo" & click on Deploy Service Group.
- Go to System Administration -> Setup -> Services & Application Integration Framework -> Inbound Ports
- Find your "HcmWorkerImportDemo" Inbound port & Copy the WSDL Address.
- Create a C# Console Application.
- Right click on your solution -> add Service Reference -> Paste the WSDL Address
- Type the Reference Name like "ABC"
- Include ABC as a namespace.
- Modify the main() method with the below code :
HcmWorkerImportServiceClient proxy = new HcmWorkerImportServiceClient();
CallContext context = new CallContext();
context.Company = "ceu"; //Company Name
AxdHcmWorkerImport worker = new AxdHcmWorkerImport();
AxdEntity_HcmWorker hcmWorkerTable = new AxdEntity_HcmWorker();
AxdEntity_DirPerson_DirPerson party = new AxdEntity_DirPerson_DirPerson();
party.NameAlias = "Kuldeep";
party.Gender = AxdEnum_Gender.Male;
party.MaritalStatus = AxdEnum_DirPersonMaritalStatus.Married;
AxdEntity_DirPersonName personName = new AxdEntity_DirPersonName();
personName.FirstName = "Kuldeep";
personName.MiddleName = "Singh ";
personName.LastName = "Godara";
party.DirPersonName = personName;
hcmWorkerTable.DirPerson = party;
AxdEntity_HcmEmployment personEmployment = new AxdEntity_HcmEmployment();
personEmployment.EmploymentType = AxdEnum_HcmEmploymentType.Contractor;
personEmployment.LegalEntity = "ceu"; //Company Name
hcmWorkerTable.HcmEmployment = new AxdEntity_HcmEmployment[1] { personEmployment };
worker.HcmWorker = new AxdEntity_HcmWorker[1] { hcmWorkerTable };
try
{
proxy.create(context, worker);
Console.WriteLine("Success");
Console.ReadLine();
}
catch
{
throw;
}
12. Run the Application.
13. Cross Check your worker into AX 2012.
Enjoy DAX !!!