Hi Andre,
Thanks for the suggestion. This is how I solved the problem(s).
I've tried importing 2 positions. 1 parent and 1 child position.
Case 1
-Import 1 parent position and 1 child position together in same file (tried different ordering, same result).
-File header: PositionId, HcmPositionHierarchy_ParentPositionId, HcmPositionHierarchyType_Name
-Positions in AX are imported 'inactive', no hierarchy as 'Reports to position' not populated in AX. HcmPositionHierarchy table populated but ParentPosition fields are zero.
Case 2
-Import parent position, then import child position as separate files
-File header: PositionId, HcmPositionHierarchy_ParentPositionId, HcmPositionHierarchyType_Name
-Positions in AX are imported 'inactive', hierarchy is present and 'Reports to position' populated as expected.
Case 3
-Import parent position, then import child position as separate files
-File header: PositionId, HcmPositionHierarchy_ParentPositionId, HcmPositionHierarchyType_Name, HcmPositionDuration_ValidFrom
-Positions in AX are imported 'active', hierarchy is present and 'Reports to position' populated as expected.
-Import Employees that match the positions
-File header: PersonnelNumber, Active, ActiveFrom, ApproveGroupId, CalculateGroupId, DefaultCalculateGroupId, DefaultProfileId, Email, FirstName, HolidaysPerYear, JobId, LastName, LegalEntity, LoginCardNo, MaxHoursCalendar, MiddleName, Name, PeriodDataAreaId, PositionId, ProfileGroupId, ProjPeriodId, PromptForAction, RegistrationSetupId, RequireStartStopTime, UseTimeCard, WorkerStartDate
Note that in DmfEmployeeEntityClass, generatePosition() will be mapped and will run when JobId is part of the import. However, if a position is found then the positionWorkerAssignment is not generated.
In the DmfHcmPositionDetailEntityClass, I added the following code between the if and the else statements to get around this:
else if(_stagingToTarget && hcmPosition.RecId)
{
positionWorkerAssignment.initValue();
positionWorkerAssignment.Worker = HcmWorker::findByPersonnelNumber(entity.PersonnelNumber).RecId;
positionWorkerAssignment.Position = hcmPosition.RecId;
positionWorkerAssignment.ValidFrom = DateTimeUtil::getSystemDateTime();
positionWorkerAssignment.ValidTo = DateTimeUtil::maxValue();
positionWorkerAssignment.insert();
}
This generates the assignment records so that the Workers are assigned to the Positions when the Employee import is run.
Unfortunately, I can't seem to run an import for parent positions and child positions in the same processing group, even if I assign different Source data formats that are required to make the form validate. When I run the 'Get staging data' process it only runs the 1st migration setup in the processing group. Checking 'Execute sequentially' makes no difference either.