Skip to main content

Notifications

Announcements

No record found.

Finance | Project Operations, Human Resources, ...
Unanswered

Query in Report (2009) keep previous query value

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
    SGbron 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
    Martin Dráb 230,198 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
    SGbron 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
    Gunjan Bhattachayya 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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans