Tuesday, April 24, 2012

updating Employment history in ax 2012


static void Job2(Args _args)
{
HcmEmployment   HcmEmployment;
HcmWorker       HcmWorker;  
 Companyinfo companyinfo;
   
    ;
    while select * from HcmWorker
    {
        while select * from Companyinfo
        {
            select * from  HcmEmployment where HcmEmployment.Worker == HcmWorker.RecId
                                           &&  HcmEmployment.LegalEntity ==  Companyinfo.RecId;
            if(!HcmEmployment)
            {
                ttsBegin;
                HcmEmployment.Worker        = HcmWorker.RecId;
                HcmEmployment.LegalEntity   =  Companyinfo.RecId;  
                HcmEmployment.ValidFrom     = DateTimeUtil::newDateTime(DateTimeUtil::date(DateTimeUtil::applyTimeZoneOffset(DateTimeUtil::utcNow(), DateTimeUtil::getUserPreferredTimeZone())), 0);
                HcmEmployment.ValidTo       = DateTimeUtil::applyTimeZoneOffset(DateTimeUtil::maxValue(), DateTimeUtil::getUserPreferredTimeZone());
                HcmEmployment.insert();
                ttsCommit;
           
            }      
        }
    }
}

No comments:

How to identify the user that was used to change an object from AOT in AX2012

Get the object name for which we need to track these (user and date&time) information's. Login to SQL Server Management Studio an...