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

Notifications

Announcements

No record found.

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
    237,990 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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

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

#1
Abhilash Warrier Profile Picture

Abhilash Warrier 669 Super User 2025 Season 2

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 449 Super User 2025 Season 2

#3
Martin Dráb Profile Picture

Martin Dráb 384 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans