9 Ağustos 2017 Çarşamba

AX 2012 - Add filter for one dimension for a query's financial dimension

If you try to this with add tables you'll see you have to add lots of table to query. There is a class which do this for you DimensionProvider with AX 2012:

DimensionProvider           dimProvider = new DimensionProvider();


        dimProvider.addAttributeRangeToQuery(element.query(),element.query().dataSourceNo(1).name(),
       FieldStr(MyTable,DefaultDimension),
        DimensionComponent::DimensionAttribute,
        OMOperatingUnit::find(depRecId,OMOperatingUnitType::OMDepartment).OMOperatingUnitNumber,
            "Department",true);

BTW if you get an error like Unknown type: RefRecId it would be about EDT of your table. In my case they used RefRecId EDT instead of DimensionDefault EDT with DefaultDimension field. In your case it would be other than RefRecId. There is a bug like this with original AX table HcmEmployment.

8 Ağustos 2017 Salı

AX 2012 - Check if period closed

Ledger:

FiscalCalendars::checkModuleIsOpen(SysModule::Ledger, myTable.TransDate,FiscalCalendars::findPeriodByPeriodCodeDate(Ledger::fiscalCalendar(CompanyInfo::find().RecId),myTable.TransDate),false)

or

select firstOnly period
        where transDate >= period.StartDate  && transDate <= period.EndDate
            exists join ledgerPeriod
                where ledgerPeriod.FiscalCalendarPeriod == period.RecId &&
                      ledgerPeriod.Status != FiscalPeriodStatus::Open;
    if (period.RecId != 0)
        throw error("Fiscal period is closed!..");

Sales:

FiscalCalendars::checkModuleIsOpen(SysModule::Sales, CustInvoiceJour.InvoiceDate,FiscalCalendars::findPeriodByPeriodCodeDate(Ledger::fiscalCalendar(CompanyInfo::find().RecId),CustInvoiceJour.InvoiceDate),false)

Invent closing:

InventClosing::findClosingDate(endmth(InventJournalTrans.TransDate))

2 Ağustos 2017 Çarşamba

AX 2012 - Compile Error about Security Development Tool

Security Development Tool  is a great tool for security issues. But sometimes it would be a trouble. If you get this error you have to know reason is that tool:

Error executing code: SysSecurityRecorder_**** object does not have method 'MenuItemInvoked'.

I just found a blog which is written in french and I translated into english with Google translate (Unfortunately Google translate is terrible with turkish translates). There are two methods advised there succeeded with me:

Way #1: Delete AOD files per client computer.

Way #2: Just run this code at AX DB:

UPDATE SYSSQMSETTINGS SET GLOBALGUID = '{00000000-0000-0000-0000-000000000000}'