Request Form Values

Hi,

I have a report with a Request Form with many controls - most of them must be entered by the user, just one should be populated with a preset value taken from a table that the user may or may not choose to change.

Now the problem is - if I set the SaveValues property to Yes, the preset value may be overwritten by a previously entered value; if I set SaeValues to No all the other request values are lost and the users will have my hide. [*-)]

Any suggestion?

Just write code in the onopenform trigger to populate that one field.

And what if the user doesn’t open the request form?

My 2 cents…

The OnOpenForm-trigger is always fired, unless someone has supressed it through code
(e.g. ReportVar.USEREQUESTFORM(FALSE):wink:

But cuz this is possible, i always do something like what you want to do, in the OnInitReport-trigger.
This trigger is fired as the very first one, and if you assign values to variables in this trigger, then user can still override those values in the req.form.

This is the way I usually use:

When a report is activted somehow, the Report OnInit is triggered.
When the RequestForm is opened (incl. DataItem Request), the Requestform’s OnOpenForm is triggered.

Knowing this you can do it this way:
*Define variable boBatch as a boolean
*In Report OnInit, set boBatch := TRUE;
*In ReqForm OnOpenForm, set boBatch := FALSE;

Now you can check if the report was activated as a batch without calling the Req or not: In Report OnPreReport, check the boBatch and take action from this.

Thank you, David, Alex, Anfinnur

The problem that I’ve been facing - at least in Nav 5.01 - is that if the SaveValues property is set to Yes, the “saved value” overwrites the values set by code in OnInitReport trigger, whether it is executed from menu or it is called by an other object with USEREQUESTFORM(FALSE).

I don’t know whether this is standard navision behavior or whether it’s a flaw in the version I’m using. I just know I’ve been losing my head after this for a while.