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 report ranges using code..?

(0) ShareShare
ReportReport
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

I have the same question (0)
  • Bill 'Luther' Thompson Profile Picture
    on at

    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.

  • Hamza Saleh Profile Picture
    45 on at

    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.

  • Verified answer
    Bill 'Luther' Thompson Profile Picture
    on at

    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.
    =============================================

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