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)

How to hide a field on a report using x++ code

(0) ShareShare
ReportReport
Posted on by 665

If it's possible, I would like to hide a date field and it's label on a report using a dialog field.  For example, when the user runs the report he/she is prompted for a date range plus there is a box to check to indicate whether or not they want this date on the report.  If box is checked include date field, if not checked hide the date field.

Any ideas, suggestions, or examples would be greatly appreciated as I am very new to AX and X++ coding.

Thanks in advance,

Gary

*This post is locked for comments

I have the same question (0)
  • Community Member Profile Picture
    on at

    Hey Gary,

    A good example for this, among many, is the SalesHeading report.  (Found in AR > Reports > Transactions > Sales Order > Sales order.

    There are two check boxes on the dialog box.

    You can look in the dialog() method to see how these are added to the dialog:

      fieldFormLetters    = dialog.addFieldValue(typeid(NoYes), formLetters,     "@SYS1402", "@SYS83391");
        fieldTotals         = dialog.addFieldValue(typeid(NoYes), totals,       "@SYS8311", "@SYS83393");

    Then in the fetch() method, certain controls visible properties are set to false based on the check boxes values.  So in the following if forms and totals check boxes are not checked, set the visible property to false for some of the reports controls:

    public boolean  fetch()
    {
        boolean  ret;
        ;

        if (!formLetters)
        {
            lastPackingSlipDate.visible(false);
            lastPackingSlip.visible(false);
            lastInvoiceDate.visible(false);
            lastInvoice.visible(false);
        }
        if (!totals)
        {
            salesTable_CurrencyCode.visible(false);
            salesTable_OrderedAmount.visible(false);
            salesTable_InvoicedAmount.visible(false);
            contributionMargin.visible(false);
        }

        ret = super();

        return ret;
    }


    Simple as that!  :)

    Hope this helps.

    Kind regards.

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