This code will be used to find out the Reporting Hierarchy positions In AX 2012
class RecursionPosition
{
str UserId;
}
void recursiveCallProj(HcmPositionRecid _position = 0)
{
HcmPositionHierarchy HcmPositionHierarchy;
HierarchyPosition hierarchyPosition;
HcmPosition posi;
HcmWorker work;
int64 recid;
;
while select HcmPositionHierarchy
where HcmPositionHierarchy.ParentPosition == _position
{
select Posi where posi.RecId == HcmPositionHierarchy.Position;
recid = hcmposition::getWorker(posi.RecId);
select work where work.RecId == recid;
hierarchyPosition.Position = work.RecId;
hierarchyPosition.userid = curuserid();
hierarchyPosition.insert();
this.recursiveCallProj(HcmPositionHierarchy.Position);
}
}
public static void postion(str userid)
{
HcmPositionRecid _position; //= 5637144597;
HcmPositionHierarchy HcmPositionHierarchy;
RecursionPosition RecursionPosition;
HcmPosition posi;
int64 recid;
HcmWorker work;
HierarchyPosition hierarchyPosition;//temp Table
;
_position = HcmPositionWorkerAssignment::getActivePositionWorkerAssignment(HcmWorker::find(HcmWorker::userId2Worker(userid)).RecId).Position;
//_position = HcmPositionWorkerAssignment::getActivePositionWorkerAssignment(HcmWorker::findByPersonnelNumber(personnelno).RecId).Position;
RecursionPosition = new RecursionPosition();
while select HcmPositionHierarchy
where HcmPositionHierarchy.ParentPosition == _position
{
select Posi where posi.RecId == HcmPositionHierarchy.Position;
recid = hcmposition::getWorker(posi.RecId);
select work where work.RecId == recid;
hierarchyPosition.Position = work.RecId;
hierarchyPosition.userid = curUserId();
hierarchyPosition.insert();
RecursionPosition.recursiveCallProj(HcmPositionHierarchy.Position);
}
}
class RecursionPosition
{
str UserId;
}
void recursiveCallProj(HcmPositionRecid _position = 0)
{
HcmPositionHierarchy HcmPositionHierarchy;
HierarchyPosition hierarchyPosition;
HcmPosition posi;
HcmWorker work;
int64 recid;
;
while select HcmPositionHierarchy
where HcmPositionHierarchy.ParentPosition == _position
{
select Posi where posi.RecId == HcmPositionHierarchy.Position;
recid = hcmposition::getWorker(posi.RecId);
select work where work.RecId == recid;
hierarchyPosition.Position = work.RecId;
hierarchyPosition.userid = curuserid();
hierarchyPosition.insert();
this.recursiveCallProj(HcmPositionHierarchy.Position);
}
}
public static void postion(str userid)
{
HcmPositionRecid _position; //= 5637144597;
HcmPositionHierarchy HcmPositionHierarchy;
RecursionPosition RecursionPosition;
HcmPosition posi;
int64 recid;
HcmWorker work;
HierarchyPosition hierarchyPosition;//temp Table
;
_position = HcmPositionWorkerAssignment::getActivePositionWorkerAssignment(HcmWorker::find(HcmWorker::userId2Worker(userid)).RecId).Position;
//_position = HcmPositionWorkerAssignment::getActivePositionWorkerAssignment(HcmWorker::findByPersonnelNumber(personnelno).RecId).Position;
RecursionPosition = new RecursionPosition();
while select HcmPositionHierarchy
where HcmPositionHierarchy.ParentPosition == _position
{
select Posi where posi.RecId == HcmPositionHierarchy.Position;
recid = hcmposition::getWorker(posi.RecId);
select work where work.RecId == recid;
hierarchyPosition.Position = work.RecId;
hierarchyPosition.userid = curUserId();
hierarchyPosition.insert();
RecursionPosition.recursiveCallProj(HcmPositionHierarchy.Position);
}
}
No comments:
Post a Comment