web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Unanswered

Query in Report (2009) keep previous query value

(0) ShareShare
ReportReport
Posted on by 157

Hello Everyone

I want to print a report (2009) [NOT SSRS from a button that I have in a form. 

I create a new button which have my main table as a datasource and after that I overide the init method 

public void init()
{


     MyTable myTable;

     ;

     super();

     myTable = element.args().record();

     this.query().dataSourceTable(tablenum(MyTable)).addRange(fieldnum(MyTable, Field_1)).value(myTable.Field_1);

}

When I debuged it, it seems like to take the correct value from the query but always in the dialog it returns an old one  Field_1 value, which now does not even exist in my records. 

I read that a method parmLoadFromSysLastValue(false) can do what I am trying to do here but it seems that is not in this or query methods. 

Does anyone know how I can pass this issue?

I have the same question (0)
  • Gunjan Bhattachayya Profile Picture
    35,423 on at

    Hi,

    Have you tried using findOrCreateQuery()? Maybe something like this -

    SysQuery::findOrCreateRange(this.query().dataSourceTable(tablenum(MyTable)), fieldNum(MyTable, Field_1)).value(queryValue(myTable.Field_1));

  • SGbron Profile Picture
    157 on at

    Hello Gunjan

    Thank you for your reply.

    Yes, I also had tried this one but I had the same issue.

    I just found what cause this problem.

    It was the usage data. I cleared everything and took the correct one. 

    But everytime I have to clear the usage data.... and that is not optimal...

  • Martin Dráb Profile Picture
    239,385 Most Valuable Professional on at

    I don't really remember MorphX reports anymore, but it indeed sounds like that you add a range before the previously-used query is loaded from SysLastValue (and therefore your code has no effect).

    Therefore you have two options. Either prevent loading from SysLastValue, or let it load and change query ranges afterwards.

    You can use the debugger to find out where the loading happens and which conditions are used there. I would start by checking if it happens in super() of dialog().

  • SGbron Profile Picture
    157 on at

    Thank you both for the help.

    The solution was to create a new method in the report named mustLoadSaveQuery()

    as below

        public boolean mustLoadSaveQuery()

        {

              return false;

        }

    That solves the issue.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 689

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 606 Super User 2026 Season 1

#3
CP04-islander Profile Picture

CP04-islander 356

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans