Skip to main content
Dynamics 365 Community / Forums / Finance forum / Dynamic Query in D365 ...
Finance forum
Suggested answer

Dynamic Query in D365 Finance & Operations

editSubscribe (0) ShareShare
ReportReport
Posted on by
Hello,

I am facing an issue where I am trying to use method clearLinks() on the form Datasource Query, but it is not working as expected and instead it is adding the same datasource over and over again to the parent datasource whenever executeQuery() method is called. Any suggestions as to how this issue can be resolved ?? 
  • Suggested answer
    Martin Dráb Profile Picture
    Martin Dráb 222,562 Super User on at
    Dynamic Query in D365 Finance & Operations
    No, clearLinks() isn't adding the same data source again. It seems that you have your code calling addDataSource() every time.
     
    Consider if you must add the data source in code - maybe you should add it in the form designer and merely disable it in code when you don't need it.
     
    If you must add it in code, and it must be in executeQuery(), not init(), you can store the QueryBuildDataSource object in a form-level variable. When calling executeQuery() again, you'll use the object from the variable, if set. Alternatively, you could check if the query already contains the data source (e.g. by using SysQuery::findOrCreateDataSource()).

Helpful resources

Quick Links

What Motivates a Super User?

We know many of you visit the Dynamics 365 Community and Power Platform…

Demystifying Copilot with Sundar…

Industry experts answer burning questions directly from our amazing Community…

Enabling Copilot Case and Conversation…

Agents can easily recap an ongoing chat, transcribe a voice conversation…

Leaderboard

#1
Andre Arnaud de Calavon Profile Picture

Andre Arnaud de Cal... 283,030 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 222,562 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,138

Product updates

Dynamics 365 release plans