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 :
Microsoft Dynamics AX (Archived)

Set default parameter values

(0) ShareShare
ReportReport
Posted on by

Hi,

I have a report that uses a Data Provider. The data provider requires two parameters, "start date" and "end date" which are set in a data contract and passed to the data provider. When the report is published to AX it all works fine. I'm  able to select the start and end date and run the report and see the expected results.

What I would like to do is automatically set the end date to today and the start date to 7 days ago but I cannot figure out how to set default parameter values. Are they set in the contract? Can anyone provide an example or point me to a tutorial?

Thanks in advance.

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Dan Emreus Profile Picture
    1,162 on at

    Create this method on the contract:

    public void initialize()

    {

       YourStartDate = systemDateGet() -7;

       YourEndDate  = systemDateGet();

    }

  • Community Member Profile Picture
    on at

    Thanks Dan for your response.

    I've tried what you suggest already, but couldn't get it to work. I'm obviously doing something wrong. My class Declaration looks like this:

    [DataContractAttribute]

    class HSP_XXX_RickSrsContract

    implements SysOperationInitializable

    {

       TransDate startingDate;

       TransDate endingDate;

    }

    and my initialize method looks like this:

    public void initialize()

    {

       startingDate = systemDateGet()-7;

       endingDate = systemDateGet();

    }

    and my parms look like this:

    [DataMemberAttribute("endDate")]

    public TransDate parmEndDate(TransDate _endingDate = endingDate)

    {

       endingDate = _endingDate;

       return endingDate;

    }

    [DataMemberAttribute("startDate")]

    public TransDate parmStartDate(TransDate _startingDate = startingDate)

    {

       startingDate = _startingDate;

       return startingDate;

    }

    When I run the report in AX, I'm still seeing the old values in the start and end date fields, not the dates initialized above? Also, If I put a break point in the initialize method, it doesn't get hit when I run a test job I have set up?

    Thanks again,

    Rick.

  • Suggested answer
    Dan Emreus Profile Picture
    1,162 on at

    I do not see why this should not work. Could it be a CIL- or a syslastvalue problem?

    /Dan

  • adam260 Profile Picture
    1,871 on at

    you could always set up the defaults within the srrs report on the parameters themselves?

  • Community Member Profile Picture
    on at

    Hi Dan,

    I did a incremental CIL build (I always do),but this made no difference. I think it maybe a syslastvalue problem because my old values are always populated regardless of what I do. I'm not sure how to fix this problem?

    Rick.

  • Community Member Profile Picture
    on at

    Hi Adam,

    I tried setting the parameters by default in the report but AX still overrides them. If I run the report in plain old SSRS via Report Manager, with no AX intervention, the parameters are populated fine, the problem only occurs when I run the report from AX.

    Rick.

  • Suggested answer
    Community Member Profile Picture
    on at

    I've written a UI Builder class that extends SrsReportDataContractUIBuilder and set the date values in the build method. This seems to work how I want, so I will stick with it.

  • Dan Emreus Profile Picture
    1,162 on at

    I do not know why it did not work for you before but am glad that you found another solution that did.

  • Community Member Profile Picture
    on at

    Hi, just wondering how did you set it in the build method of UIBuilder class.. hoping you can help me out thanks.

  • Suggested answer
    Syed Wajid Ali Profile Picture
    25 on at

    Use Business Logic following business logic provide parameters value on both end in SSRS and AX

    [DataMethod(), AxSessionPermission(SecurityAction.Assert)]

    public static DataTable DateFromToDefaultValuesDataTable()

    {

    DataTable dateRangeTable = new DataTable();

    dateRangeTable.Columns.Add("DateFrom", typeof(DateTime));

    dateRangeTable.Columns.Add("DateTo", typeof(DateTime));

    dateRangeTable.Rows.Add(new object[] { DateTime.Today.AddDays(-7), DateTime.Today });

    return dateRangeTable;

    }

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 > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans