Skip to main content
Dynamics 365 Community / Forums / Finance forum / QueryBuildRange object...
Finance forum
Answered

QueryBuildRange object not initialized

editSubscribe (2) ShareShare
ReportReport
Posted on by 93
Hi, I got the following message when cleaning up and adding some ranges to a formdatasource
 
 
The code where this case occurs is as follows:
 
I have observed that if I comment the line clearRanges the error disappears and performs its function, since the purpose of this code is to enter a form and add to its datasource ranges. However, I find it strange that this error occurs, because I have done this same process many times before for other forms and I have not got this error.
Attachments
  • Verified answer
    Waed Ayyad Profile Picture
    Waed Ayyad 2,305 on at
    QueryBuildRange object not initialized
    Hi,
     
    1-I got your point, but I think you can do it in another way you can clear the ranges on the init of the form that will open when you click on the tile.
    if(element.args()&& element.args().menuItemName() == menuitemdisplaystr(YoueMenuItemName))
    {
       YourDataSource_ds.queryBuildDataSource() 
    }
     
     
    2- Try to change copy caller query property to No on the Display Menu Item, but you should make sure the menu item is only used only on this place.
     
    Thanks,
    Waed Ayyad
     
    If this helped, please mark it as "Verified" for others facing the same issue
     
  • Jesus Profile Picture
    Jesus 93 on at
    QueryBuildRange object not initialized
    Hi @Waed, I understand what you are showing me but my case is peculiar, let me explain:
    I have a form with a certain amount of Tiles Button. These tiles button show a counter from a query that I launch by doing an override of the getData method. The Tile button allows you, when you click on it, to enter the form it refers to. Then, so that, when you enter the form, it filters the same as in the previously mentioned query, I make an override of the clicked method and call the form from the code (that's why I have the code shown above). And as I said, I have replicated this code in other Tiles button and it has not given me any kind of problem, it has worked correctly, but in this case it has not.
  • Suggested answer
    Waed Ayyad Profile Picture
    Waed Ayyad 2,305 on at
    QueryBuildRange object not initialized
    Hi,
     
    You mean you need to get the current Query on your form DataSource?
     
    You can add the following:
     
    fds                = YourDataSourceName_ds.Query().dataSourceTable(tablenum(YourTable));
    Or 
    queryWHSWaveTable  = YourDataSourceName_ds.Query().dataSourceTable(tablenum(YourTable));
    Use one variable for QueryBuildDatasource fds or queryWHSWaveTable . No need for this line queryWHSWaveTable = fds.queryBuildDataSource();

    Don't forget to continue the code based on the chosen variable.  
     
    Also see the following link:
     

     
    Thanks,
    Waed Ayyad
    If this helped, please mark it as "Verified" for others facing the same issue
     
  • Jesus Profile Picture
    Jesus 93 on at
    QueryBuildRange object not initialized
    Hi @Lawan, its the clicked method from a Tile Button
  • Jesus Profile Picture
    Jesus 93 on at
    QueryBuildRange object not initialized
    Hello @Waed, thank you for the information you have provided. I'll tell you in parts: 
    1- I use FormDataSource to save the datasource that initially has the form and clean the ranges that it adds in a standard way and then add mine.
    2- I have tried the FormRun.add method and when I launch it, the compiler informs me that this method does not exist in the FormRun.
  • Layan Jwei Profile Picture
    Layan Jwei 2,960 Super User on at
    QueryBuildRange object not initialized
    Hi,
     
    What method are you using?
  • Suggested answer
    Waed Ayyad Profile Picture
    Waed Ayyad 2,305 on at
    QueryBuildRange object not initialized
    Hi,
     
    I noticed something on your code. Why you define fds and then use queryWHSWaveTable = fds.queryBuildDataSource();
     
    You can use queryWHSWaveTable  = FormRun.add(FormDatasourceStr(WHSWaveTableListPage, WHSWaveTable);
     
    When you debug the code, did you sure t that this line  fds= FormRun.add(FormDatasourceStr(WHSWaveTableListPage, WHSWaveTable); not null?
     
    Thanks,
    Waed Ayyad
    If this helped, please mark it as "Verified" for others facing the same issue
     

Helpful resources

Quick Links

New Blog Features Released!

Check out the new community blog features for viewers and authors…

Demystifying Copilot with Sundar Raghavan

Sundar explains how Copilot for Service is meant to function separately...

Business Process Guidance Badges and New…

The Microsoft Success by Design is the framework for implementing Dynamics 365…

Leaderboard

#1
Andre Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 222,989 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,140

Featured topics

Product updates

Dynamics 365 release plans