Create Custom Dialog on Form with Customer Lookup for a Specific Financial Dimension in D365 FinOps

By Bill Thompson | April 11, 2019

Create custom dialog on form with customer lookup for a specific financial dimension in d365 finops

Recently I had a request to create a custom form in Dynamics 365 Finance and Operations. One requirement was that prior to the form opening, it would prompt the user for a date (defaulted in with the current date) and a value from a specific financial dimension.  The working prompt form would look like this (with the custom lookup code on the financial dimension):

Custom dialog on form opening

So, here’s how I would create a custom dialog on a form with a customer lookup for a specific financial dimension in D365 FinOps. The dialog code itself is not hard to do.  It simply is placed in the init() method of the main form:

/// <summary>
    /// Build the dialog that prompts the user for a date and a site to process
    /// </summary>
    public void init()
    {
        super();

        // build the dialog for prompt
        Dialog dialog = new Dialog("Label goes here",element);
        DialogField dfDate = dialog.addField('Date1980','Date');
        dfDate.value(DateTimeUtil::getToday(DateTimeUtil::getUserPreferredTimeZone()));

        DialogField dfDimValue = dialog.addField('DimensionValue','LocationSite');
        FormBuildStringControl control;
        control = dfDimValue.control();

        // use the custom lookup
        control.registerOverrideMethod('LookUp','dimLookup',this);

        // if we click OK, we run, otherwise, close the form
        if (dialog.run())
        {
            dlDate = dfDate.value();
            dlDimValue = dfDimValue.value();

            boolean dlClosed = dialog.closedOk();

            if (dlClosed)
            {

		   // code does in here
            }
        }
        else
        {
            element.close();
        }

    }

This key line in the code above is the following:

control.registerOverrideMethod('LookUp','dimLookup',this);

This line allows us to override the lookup method of the control in the dialog, and replace it with our custom code.  This method exists on the form as well.

/// <summary>
    /// This is the custom lookup code for the LocationSite financial dimension field on the user prompt dialog
    /// </summary>
    /// <param name = "_control"></param>
    private void dimLookup(FormStringControl _control)
    {
        
        Query query = new Query();
        QueryBuildDataSource qbdsDimensionFinancialTag = query.addDataSource(tableNum(DimensionFinancialTag));
        QueryBuildRange qbrFinancialTagCategory = qbdsDimensionFinancialTag.addRange(fieldNum(DimensionFinancialTag, FinancialTagCategory));
        qbrFinancialTagCategory.value(strFmt('%1', DimensionAttribute::findByName(dimName, false).financialTagCategory()));

        SysTableLookup sysTableLookup = sysTableLookup::newParameters(tableNum(DimensionFinancialTag), _control,true);
        sysTableLookup.addLookupfield(fieldNum(DimensionFinancialTag, Value), true);
        sysTableLookup.addLookupfield(fieldNum(DimensionFinancialTag, Description));
        sysTableLookup.addSelectionField(fieldNum(DimensionFinancialTag, FinancialTagCategory));
        sysTableLookup.parmQuery(query);

        sysTableLookup.performFormLookup();
    }

This is pretty standard lookup code using the SysTableLookup class.  That is all that is needed to accomplish my requirements (other than some specific requirement code that is not relevant here).

You can use this method to create any custom dialog form opening and have a customer lookup for any specific financial dimension in D365 Finance and Operations. If you have any more questions on how to do this yourself, please contact us.

Related Posts

Recommended Reading:

Managing Your Business Through Uncertain Times Using Dynamics 365 Finance and Operations

  Dynamics 365 Finance and Operations (F&O) can help you make informed decisions on how to move your business forward. […]

Read the Article
5.13.22 Power Platform

Using Power BI Object Level Security

  The following article will demonstrate how to use Power BI Object Level Security to disable column data based on […]

Read the Article
5.12.22 Dynamics CRM

How to Use the Stoneridge Support Portal

Stoneridge Software’s support portal is an intuitive and useful function that makes it easy for you to access resources to […]

Read the Article
5.6.22 Dynamics GP

Dynamics GP Transaction Removal: Purchase Orders

  Are you having performance issues with Purchase Orders?  Do you find that there are old Purchase Orders on your […]

Read the Article
5.5.22 Dynamics GP

The Real Story about the Long-Term Future of Dynamics GP Support

I’ve seen a number of people put forward comment that Dynamics GP is going away and you have to get […]

Read the Article

New Features in Dynamics 365 Business Central 2022 Wave 1 Release – Financial Enhancements

The Dynamics 365 Businses Central 2022 Wave 1 Release has a lot of new and exciting features to help your […]

Read the Article
4.29.22 Dynamics GP

Dynamics GP Transaction Removals: Bank Reconciliation

  This is part 2 of a 3 part series on Dynamics GP Transaction Removals. These quick tips will hopefully […]

Read the Article
4.28.22 Dynamics GP

Uncommonly Used Features – Integrate Purchasing and Payables to Fixed Assets in Dynamics GP

Being able to integrate Purchasing and Payables to Fixed Assets in Dynamics GP will help you create visibility for your […]

Read the Article

New Features in the Dynamics 365 Business Central 2022 Wave 1 Release – Ease-of-Use Features

  There are many new features in the Dynamics 365 Business Central 2022 Wave 1 Release to get excited about! […]

Read the Article

Start the Conversation

It’s our mission to help clients win. We’d love to talk to you about the right business solutions to help you achieve your goals.

Subscribe To Our Blog

Sign up to get periodic updates on the latest posts.

Thank you for subscribing!

X