web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Dimension attribute value selected in query prompt

(0) ShareShare
ReportReport
Posted on by 1,244

Hi all,

I run the custageingreport query, add a filter for "dimension.Channel" then I am trying to access value selected in a query's prompt (eg. CustAgeingReport query). I have written the following code but it is returning as null/ empty.


Query q = new Query(queryStr(CustAgingReport)); QueryRun qRun; container conQr; ; qRun = new QueryRun(q); qRun.prompt(); conQr = SysQuery:: getDimensionAttributeValueFromQueryRun( qRun, q.dataSourceTable(tableNum(CustTable)).name(), 'DefaultDimension', DimensionComponent::DimensionAttribute, 'Channel');

What am I doing wrong here?

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Vilmos Kintera Profile Picture
    46,149 on at

    The functionality you are calling is not compatible with the query you are feeding in. It is missing the datasource which would be about the dimensions. Most likely it is failing in \Classes\DimensionProvider\getAttributeValueFromQueryRun method on the line which tries to get the pivoted attribute table name, something like DimAttCol_CustTable_DefaultDimension_56789012345 (RecId of the attribute) from your query datasource.

  • Verified answer
    Vilmos Kintera Profile Picture
    46,149 on at

    Actually the documentation states the solution here at the bottom.

    https://msdn.microsoft.com/en-us/library/sysquery.getdimensionattributevaluefromqueryrun.aspx

    Here is my test code which works for a Cost center dimension for my test customer account:

        Query                   q   = new Query(queryStr(CustAgingReport));
        QueryRun                qRun;
        container               conQr;
        
        // Add dimension attribute to the query
        SysQuery::addDimensionDataSource(
            q,
            q.dataSourceTable(tableNum(CustTable)).name(),
            fieldStr(CustTable, DefaultDimension),
            DimensionComponent::DimensionAttribute,
            'Center');
        
        // Filter for the desired customer which has default dimension set
        SysQuery::findOrCreateRange(q.dataSourceTable(tableNum(CustTable)), fieldNum(CustTable, AccountNum))
            .value(queryValue('VilmosTestCustomer'));
    
        qRun    = new QueryRun(q);
        info(qRun.toString());
        
        // Fetch first record
        qRun.next();
        
        // Get Cost center attribute value
        conQr = SysQuery::getDimensionAttributeValueFromQueryRun(
            qRun,
            q.dataSourceTable(tableNum(CustTable)).name(),
            fieldStr(CustTable, DefaultDimension),
            DimensionComponent::DimensionAttribute,
            'Center');
    
        info(conPeek(conQr, 2));
    
  • Abhinay Tharwal Profile Picture
    1,244 on at

    Thank you Vilmos! This has resolved the issue and made me understand my mistake.

    Regards,

    Abhinay

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
CP04-islander Profile Picture

CP04-islander 26

#2
imran ul haq Profile Picture

imran ul haq 8

#3
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 4 Super User 2026 Season 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans