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?

  • SGbron Profile Picture
    157 on at
    RE: Query in Report (2009) keep previous query value

    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.

  • Martin Dráb Profile Picture
    231,925 Most Valuable Professional on at
    RE: Query in Report (2009) keep previous query value

    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
    RE: Query in Report (2009) keep previous query value

    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...

  • Gunjan Bhattachayya Profile Picture
    35,421 on at
    RE: Query in Report (2009) keep previous query value

    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));

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

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 293,245 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,925 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156 Moderator

Leaderboard

Product updates

Dynamics 365 release plans