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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

How to enable/disable dynamically added data source

(0) ShareShare
ReportReport
Posted on by 2,120

Hi Techies,

I want to enable/disable a dynamically added data source in a code at a particular condition. If the values of the fields(FromDate and ToDate) are blank then it should be disabled else it should enable. I tried doing this ->qbds.childDataSourceNo(2).enabled(true); but it is showing error - 'Query does not contain 2 datasources'

Below is my code

QueryBuildDataSource qbds = ds.addDataSource(tableNum(LedgerJournalTrans));
qbds.relations(true);
qbds.joinMode(JoinMode::ExistsJoin);
qbds.addRange(fieldNum(LedgerJournalTrans,TransDate)).
value(strFmt('%1..%2',formRun.parmFromDate(),formRun.parmTodate()));


Can anyone help me here,

Any response is appreciated!

Thanks

*This post is locked for comments

I have the same question (0)
  • Sangram Shinde Profile Picture
    2,120 on at

    I want to show data according to the dates selected, in current situation- if i select these dates on form, the code is adding this data source and showing me data as required, now if I remove the dates then it should display all records on form without considering this date filter, in my condition the added data source is remaining in a query and showing previous data.

  • Suggested answer
    nmaenpaa Profile Picture
    101,172 Moderator on at

    One solution would be keeping your joined data source, but passing dateNull() and maxDate() as the date range.

    In your code you have introduced a new QueryBuildDataSource which has one data source table.

    Therefore qbds.childDataSourceNo(2).enabled(true) can't work, can it? Or is qdbs referring to something else in the place where you are using it?

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans