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)

Adding a view as a secondary datasource on a form

(0) ShareShare
ReportReport
Posted on by 692

Hi

Is it possible to add the DirPartyView as a form datasource to link to DirPartyTable?

I have tried, but it doesnt seem to join correctly. It should be DirPartyTable.RecId == DirPartyView.Party

Thanks,
Joe

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Martin Dráb Profile Picture
    237,948 Most Valuable Professional on at

    You'll have to help AX with the relation. If you're joining the datasources, add the link by the following piece of code in init() of the DirPartyView datasource.

    this.queryBuildDataSource().addLink(fieldNum(DirPartyTable, RecId), fieldNum(DirPartyView, Party));

    If you're linking them, use a dynalink instead.

  • JoeBrewer Profile Picture
    692 on at

    Thanks Martin. That was exactly what I was looking for

  • Jorgen Dam Profile Picture
    35 on at

    And how is this done in AX 2009, where this.querybuildDataSource() doesn't apply?

  • Martin Dráb Profile Picture
    237,948 Most Valuable Professional on at

    E.g. this.query().dataSourceTable(tableNum(MyTable)).

  • Jorgen Dam Profile Picture
    35 on at

    Hi Martin

    Thanks for your quick reply.

    Yes I've tried that, but getting the "The data source is not embedded within a (parent) data source." runtime error.

    I have a Table ActiveDealers with only one field DealerId, as the parrent table.
    I want to join that with the DealersView (which contains aggregated info for the dealers)
    I've added both as data sources to the form and set join source of DealersView to ActiveDealers (LinkType passive, as I want to add active dealers in the form)

    I added this code to the init() of DealersView datasource:

    super();
    
    this.query().dataSourceTable(tablenum(DealersView)).addLink(
    fieldnum(ActiveDealers, DealerId), fieldNum(DealersView, DealerId));


    Been fighting with this issue all day now, so any input is appreciated :)

    Best regrads,
    Jorgen Dam

  • Martin Dráb Profile Picture
    237,948 Most Valuable Professional on at

    You said you wanted to join the datasources, but you didn't do that - that's why you got the error. Use InnerJoin instead of the passive link.

    If you actually want to use a link instead of a join, you would have to use a dynalink (as I already mentioned in the first reply).

  • Jorgen Dam Profile Picture
    35 on at

    I wanted to use the passive link as I wanted to edit the parrent table and for good reason not the child table as it is a view.

    BUT, I used the InnerJoin instead and overrided the write method om the view datasource.

    Everything works perfectlly now :)

    Thanks a lot  Maritn

  • Martin Dráb Profile Picture
    237,948 Most Valuable Professional on at

    I know it's confusing, because the single property (LinkType) is used for two very different things:

    • joins (InnerJoin, OuterJoin, ExistsJoin, NotExistsJoin) - create a single query
    • links (Passive, Delayed, Active) - create separate queries

    You obviously have to work very differently if you have a single query (composed of two joined tables), or two separate queries (connected through a dynalink).

  • cujamison Profile Picture
    5 on at

    Thank you Martin for your answer. This answered a big problem I was having today. I appreciate all your responses throughout the various AX community blogs.

  • OrangeRocks Profile Picture
    700 on at

    What about if a View has to be added to the query:

    ListPage -> DataSource -> Query -> DataSourceTable01-> View.

    I am trying to overwrite the init() method of the query  (which is the data source) in order to link the view to the DataSourceTable01

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