Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX (Archived)

Form with multiple DataSources pointing on the same unique Table

(0) ShareShare
ReportReport
Posted on by 350

Hello Everybody

I'm trying to make a Form with 2 DataSources which point to the same Table (DimensionAttribute for example).

My need is to display on a Grid 2 columns as financial dimenions (Departement and Site for example).

So under each DataSource i override the init() method like this :

For the first DataSource :

public void init()
{
    super();

    this.query().dataSourceTable(tableNum(DimensionAttribute)).addRange(fieldNum(DimensionAttribute,Name)).value('DEPARTMENT');
    this.query().dataSourceTable(tableNum(DimensionAttribute)).findRange(fieldNum(DimensionAttribute,Name)).status(RangeStatus::Locked);


}

For the secondDataSource :

public void init()
{
    super();

    this.query().dataSourceTable(tableNum(DimensionAttribute)).addRange(fieldNum(DimensionAttribute,Name)).value('SITE');
    this.query().dataSourceTable(tableNum(DimensionAttribute)).findRange(fieldNum(DimensionAttribute,Name)).status(RangeStatus::Locked);


}


But the problem is that when i execute the Form i see that only the first Column (with DEPARTMENT financial dimension) is filtred and the  RangeStatus::Locked is applied.

for the second column no filter is applied and RangeStatus::Locked is not applied also ! and so for this second column all financial dimensions are listed (DEPARTMENT, SITE, CENTERCOST ....).

I remarked also that if remove my init() method from the first DataSource and execute the form that the filter on 'SITE financial dimension RangeStatus::Locked are applied for the first column instead of the second one !

What am I missing please ? 

Thanks.

*This post is locked for comments

  • Suggested answer
    Martin Dráb Profile Picture
    Martin Dráb 230,458 Most Valuable Professional on at
    RE: Form with multiple DataSources pointing on the same unique Table

    If you wanted to use dataSourceTable(), using just the first argument isn't enough. You must also use the second argument, _occurrence, which allows distinguishing between different query data sources for the same table.

    But I wouldn't do that - it's unnecessarily complicated and error-prone.

    Instead, use queryBuildDataSource() of form data sources - it'll give you the right query data source straight away, without having to deal with numeric indexes.

    If you put code to init() method of each data source, as JauB did, you can simply use this.queryBuildDataSource().

    If you need it outside the context of a data source, refer to it by its name, e.g. MyTable_ds.queryBuildDataSource().

  • RE: Form with multiple DataSources pointing on the same unique Table

    Hi JauB,

    To resolve this issue, what exactly did you do?

  • Suggested answer
    Martin Dráb Profile Picture
    Martin Dráb 230,458 Most Valuable Professional on at
    RE: Form with multiple DataSources pointing on the same unique Table

    Using this.queryBuildDataSource() is easier. :-)

  • JauB Profile Picture
    JauB 350 on at
    RE: Form with multiple DataSources pointing on the same unique Table

    Very cool. Wokring like a charm.

    Thanks Crispin :)

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

Congratulations 2024 Spotlight Honorees

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December

Congratulations to our December super stars! 🥳

Start Your Super User Journey

Join the ranks of our community heros! 🦹

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,711 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,458 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans