Monday, 26 August 2013

How to get Employee Dimensions in AX 2012

Dear Friends,

Here is the sample code to find the Employees who has CostCenters attached.

static void getEmployeeWhoHasCostCenter(Args _args)
{
        HcmEmployment                         hcmEmployment;
        DimensionAttributeValueSetItem  setItem;
        DimensionAttributeValue              dimAttrValue;
        DimensionAttribute                      dimAttribute;
        ;
   
        dimAttribute    = DimensionAttribute::findByName('CostCenter');
   
        while select hcmEmployment
            join RecId, DisplayValue from setItem
                where setItem.DimensionAttributeValueSet ==   

                                                    hcmEmployment.DefaultDimension
            join dimAttrValue
                where dimAttrValue.RecId == setItem.DimensionAttributeValue &&
                dimAttrValue.DimensionAttribute == dimAttribute.RecId       &&
                dimAttrValue.IsDeleted == false
        {
            info(strFmt("Employee = %1  %2 = %3 ",
                HcmWorker::find(hcmEmployment.Worker).PersonnelNumber,    

                dimAttribute.Name, setItem.DisplayValue));
       }

}

No comments:

Post a Comment