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)

How to enable/disable dynamically added data source

(0) ShareShare
ReportReport
Posted on by 2,114

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,114 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,160 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

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