Skip to main content

Notifications

Microsoft Dynamics AX (Archived)

Error executing code: QueryBuildDataSource object not initialized.

Posted on by Microsoft Employee

Hello everyone,

I am a very new developer in Dynamic AX and only know some basics. I was creating a new ListPage form which is assigned a query and i just want to simply show some records of InventTransferTable. I created a new interaction class for form. I didn't override any method in class as i want to just display some records. As i click on open the form i get the following error. What should i do? Please help.

Error executing code: QueryBuildDataSource object not initialized.

2016_2D00_04_2D00_14_5F00_13_2D00_03_2D00_55.png

*This post is locked for comments

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Error executing code: QueryBuildDataSource object not initialized.

    For Sohaib:

    1. I tried to add a custom filter in code of InventTransferOrders but i was unable to find the exact method where i have to put the code. Can you help me to find the exact line or method of code where i can apply my filter in InventTransferOrders. (This is the same warehouse filter which i am applying in above screenshot.) 

    2. Thanks Sohaib your suggested findRange method solved the issue for now, i will try to investigate this issue in future.

    For Dominic:

    I get following error when i try to debug anything.

    2016_2D00_04_2D00_19_5F00_15_2D00_51_2D00_33.png

  • dolee Profile Picture
    dolee 11,279 on at
    RE: Error executing code: QueryBuildDataSource object not initialized.

    Have you try using the debugger to see why the init method is called twice?

  • Verified answer
    Sohaib Cheema Profile Picture
    Sohaib Cheema 46,610 User Group Leader on at
    RE: Error executing code: QueryBuildDataSource object not initialized.

     

    1. InventTransferOrders is primarily used for Transfer Orders. There is no ListPage for Transfer Order. Instead, a non-ListPage form is available at below locations to handle transfer orders

      Inventory Management >> Periodic >> Transfer Orders

      Technically form is located at below location

      AOT\Forms\InventTransferOrders (it is a non-ListPage Form)

       

    2. For your 2nd question, we need to have more details such as how many times InventTransferOrderTable is being used in your query. Query allows us to use same table for more than one time, in situations where we keep name of DataSource different, but actually name of table is same behind the scene. You can check this by looking at properties of each DataSource inside your query. Any Source code can also be responsible for this. Your code is always forcing addRange. Instead you can also make use of findRange. If range found, you can simple assign a value else you can proceed to addRange.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Error executing code: QueryBuildDataSource object not initialized.

    Thank you Sohaib and Dominic. Sorry guys that was my mistake. I had written code in init method of query which was applying dynamic filters to a table and it was not in data source of query.

    Experts i have following 2 more questions for you:

    1) Is there any built-in ListPage form available for InventTransferOrder table as we have SalesLineBackOrderListPage for SalesLine table, so that i don't have to put extra effort of creating form.

    2) Whatever i write in init method of query, the code is called for two times. For example my dynamic filter appears twice.

    2016_2D00_04_2D00_14_5F00_15_2D00_08_2D00_21.png

    2016_2D00_04_2D00_14_5F00_15_2D00_08_2D00_21.png

  • dolee Profile Picture
    dolee 11,279 on at
    RE: Error executing code: QueryBuildDataSource object not initialized.

    Hi Zahid,

    Go to the query "SalesLineBackOrderListPageTransfer" then Method node. Is the init method there? Any code written in it?

  • Sohaib Cheema Profile Picture
    Sohaib Cheema 46,610 User Group Leader on at
    RE: Error executing code: QueryBuildDataSource object not initialized.

    I repeated steps, as per you claim. But I wasn’t able to produce issue.

    • Created a Table.

    • Created a query; Dynamic Fields True

    • Created a list page with Form Template

    • Dragged my query to List Page.

    • Created an Interaction Class; No methods added to it.

    • Specified Interaction Class name into the properties of my ListPage form.

      Unable to produce issue. Here below image for your reference.

      SampleListPage.png

       

       

      Now, in general, your error message is saying that for an element QueryBuildDataSource you are trying to use it without initialization of object.

      QueryBuildDataSource is a system class. Whenever using a class, it is must to initialize its object. without construction of object we cannot call its methods. That's what error message is complaining about.

       

      If you can provide us some information to reproduce issue, we can help you further.

       

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,149 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans