Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX (Archived)

Set report ranges using code..?

Posted on by 45

Dear All,

I'm calling report using output menuItem from specified form. what i really want is to set the report Ranges by the caller record from the form so the following is the situation:

1. Output meneItem on the form.

2. On the init() method in the report the following

    tableBuffer = element.args().record();

3. The required now is to set the report query (Ranges) by using one of the TableBuff fields.

 

Please help in this,

Hamza Saleh.

 

 

*This post is locked for comments

  • Verified answer
    Re: Set report ranges using code..?

    Hello,

    I see what you are saying.  Basically, if you start from a menu item with NO record, you want to basically NOT use what is stored in usage data.  At that point, couldn't you do something like this:

    public void init()
    {
    CustTable ct;
    ;

    super();
    if (element.args().record())
    {
         this.query().dataSourceTable(TableNum(CustTable)).addRange(FieldNum(CustTable,Name)).value(ct.Name);
    }
    else
    {
         this.query().datasourceTable(TableNum(CustTable)).addRange(FieldNum(CustTable,Name)).value("");
    }

    }

    Granted, the range value would hav to make sense based on the field(s) being cleared, but I would think the above would be acceptible.  Otherwise, you may want to override the unpack method of the report to not get the usage data if the record in args() is empty as well.

    Please keep us posted.

    Best regards

    Bill 'Luther' Thompson
    Microsoft Online Support Engineer - MBS Dynamics AX Developer Support

    =============================================
    When responding to posts, please "Reply to Group" via your newsreader so that others may learn and benefit from your issue.
    =============================================

  • Hamza Saleh Profile Picture
    Hamza Saleh 45 on at
    Re: Set report ranges using code..?

    Hello,,

    Thanks a lot for your reply,

    What you said is totally right and it's already working...actually i did the same thing...

    But the problem is if you run the report from stand alone menu item without calling from active buffer and you assigned value for the customer account as following:

    1. Run report from standalone menu item according customer account number (1000).

    2. Remember it will stay as the last value range if you run the report another time soo...

    3. If you run the report from active customer on account number (2000) form to let What You said for me to run correctly...

    IT is working and the data will be fetched correctly,...but the last range which you specified before it will remain the same without any changes...i mean it will be (1000)..

    so how i can to change the LAST range value from the code...?

    Hope you got the idea...

    and thanks again for your help.

  • Re: Set report ranges using code..?

    Hello,

    Remember that when a menuitem is used, the currently active record in the datasource is assigned to the record value of Args.  So, for example, if the menu item is on a form where CustTable is the datasource, on the called form, you could do the following for the init method of the called form datasource:

    public void init()
    {
        CustTable   ct;
        ;
       
        super();
        if (element.args().record())
        {
            this.query().dataSourceTable(TableNum(CustTable)).addRange(FieldNum(CustTable,Name)).value(ct.Name);
        }
       
    }

    I have not tested this, so it may not be quite correct syntactically, but it should be pretty close to what you are asking.

    I hope this helps,

    Bill 'Luther' Thompson
    Microsoft Online Support Engineer - MBS Dynamics AX Developer Support

    =============================================
    When responding to posts, please "Reply to Group" via your newsreader so that others may learn and benefit from your issue.
    =============================================
    This posting is provided "AS IS" with no warranties, and confers no rights.

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,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans