Thursday, June 23, 2016

How to Get HcmWorker Financial dimensions in ax 2012

add the below code in HcmWorker Table method.

public static str getDimensionValue(HcmWorkerRecId _workerRecId,Name _DimensionName,
                                            utcdatetime _asOfDate = DateTimeUtil::utcNow())
{
    DimensionAttributeValueSetStorage             dimStorage;
    str                                                                dimValue;
    Counter                                                     counter;
    HcmEmployment                                 hcmEmployment;
    RecId                                                 _DefaultDimension;
    ;
    select hcmEmployment where
              hcmEmployment.Worker == HcmWorker::find(_workerRecId).RecId;

    dimStorage = DimensionAttributeValueSetStorage::find(hcmEmployment.DefaultDimension);

    for (counter=1 ; counter<= dimStorage.elements(); counter++)
    {
         if(DimensionAttribute::find(dimStorage.getAttributeByIndex(counter)).Name == _DimensionName)
         {
               dimValue = dimStorage.getDisplayValueByIndex(counter);
              // info(strfmt('%1',dimValue));
         }
    }
    return dimValue;
}

after show make a display method to financial methods.

Idisplay HcmPersonnelNumberId branch( )
{
return HcmWorker::getDimensionValue(HcmWorker::findByPersonnelNumber(this.PersonnelNumber).RecId, 'BRANCH');

}


No comments:

Post a Comment

update_recordset with joins

 update_recordset with joins update_recordSet storeTransfer         setting      TransactionId = transfertable.TransferId     join transfert...