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

Notifications

Announcements

No record found.

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,215

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,215 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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans