Search code examples
axaptamicrosoft-dynamicsdynamics-ax-2009

Open a query saved in a table in SysQueryForm AX2009


How is it possible to open a query that is saved in a table as a container in in SysQueryForm, edit the query and then save it again in the table?

I know already how to save it to the table and read it from the table, but I cannot find out how it is possible to open the query in SysQueryForm and let the user edit it and then save it.

OR

What is a good way of storing or having a query that a user can adjust and that can also be ran in the code?


Solution

  • You show the edit form via the prompt() method of class SysQueryRun. I don't show how to load and store it in a table as you mentioned that you already know how to do this.

    SysQueryRun queryRun;
    ;
    
    queryRun = loadQueryFromTable();
    if (queryRun.prompt()) // show dialog
    {
        info("Closed via 'OK'");
        saveQueryInTable(queryRun);
    }
    else
    {
        info("Closed via 'Cancel'");
    }