Showing posts with label filter. Show all posts
Showing posts with label filter. Show all posts

Tuesday, January 9, 2018

Filter AOT objects using X++ in Ax2012

Hey guys,

Let's discuss a very interesting code for the simple purpose of filtering objects in a project. I hope we all know about the standard of Ax to filter and import AOT objects in a project. So now we will see how to do it using x++ code:

static void alle_aks_ImportObjectsToProjects(Args _args)
{
    sysprojectfilterrunbase varProject;
    utilelements            aotElements;

    varProject = new sysprojectfilterrunbase();
    varProject.parmProjectNode(systreenode::createProject('Alle_GST_TaxObejcts'));
    varProject.grouping(sysprojectgrouping::AOT);

    while select name, utilLevel, RecordType, ParentId from aotElements
        where aotElements.utilLevel == UtilEntryLevel::var
        && aotElements.name like 'Tax*'
    {
        try
        {
            aotElements.reread();
            varProject.doUtilElements(aotElements);
        }
        catch (exception::Error)
        {
            throw error('Error');
        }
    }
    varProject.write();
    info('Done');
}

Here you can modify the while select query to suit your need i.e. to change the layer or the name filter.


Source: https://mydynamicsax.wordpress.com/2015/03/19/how-to-filter-aot-objects-to-a-project/

Thursday, September 10, 2015

Add KPI to Role Center AX2012

It's easy to add KPI/Indicators to the Role Centers but it's a time consuming & tiring task to add multiple KPI/Indicators to the role center. But today I have found out a quick way to do so.

Firstly just add a KPI web part to the role center page.
Go to the Page Definition in AOT, right click on it and click "View Code". Then add a small piece of code just after the ending line of KPI webpart code:

<ArrayOfIndicator xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">

After the above line add the below given code and change the Cube name & Indicator Name or other required properties of the KPI accordingly. Most importantly change the Id for every KPI.

<Indicator>
    <Id>ae413b36-9f55-40d5-ae21-a8d3ceaa83cc</Id>
    <CubeName>General ledger cube</CubeName>
    <MeasureName>Accounts receivable turnover</MeasureName>
    <DisplayTitle />
    <SliceDimensionAttribute />
    <TimePeriodsName />
    <RolePlayingTimeDimension />
    <ReportPath />
    <ValueType>Amount</ValueType>
    <IsDecreasingBetter>false</IsDecreasingBetter>
    <Visible>true</Visible>
    <IsValid>true</IsValid>
    <EnableFilters>false</EnableFilters>
    <DateFilters>
      <DateFilterItem>
        <DateTimeDimension>Acknowledgement date</DateTimeDimension>
        <TimePeriod>Current_KPI</TimePeriod>
      </DateFilterItem>
    </DateFilters>
    <NonDateFilters />
    <ReportClientMenuItem />
    <ReportWebMenuItem />
    <CompareMeasureName />
    <CompareMeasureCaption />
    <SplitOrder>Top</SplitOrder>
    <NonEmpty>true</NonEmpty>
    <SplitCount>10</SplitCount>
  </Indicator>