Search code examples
microsoft-dynamicsnavision

How do we set a default Request Page value for a Dynamics NAV report


We have a Dynamics NAV (2013R2 if it matters) report for which we need to set some default values on the Request Page. We have set the ReqFilterFields property on the first level DataItem and the correct fields are being displayed in the Request Page. We need to set default values for a couple of the ReqFilterFields. Where do we assign the default values?


Solution

  • We eventually found it. When the Report is in Design Mode,

    1. Click View, Request Page

    2. Click View, C/AL Code

    3. Put code in OnOpenPage event

      // For option fields.

      DataItemName.SETRANGE(FieldName,DataItemName.FieldName::OptionValue);

      // For standard fields.

      DataItemName.SETRANGE(FieldName,DefaultFieldValue);

    NOTE: If you are assigning a default value to a non Option field, you may need to remove the field name from the ReqFilterFields list to prevent it from displaying twice in the Request Page. Dynamics NAV 2013R2 seems to handle Option fields properly when the Option field is in the ReqFilterFields list and is also assigned a default value in the OnOpenPage event.