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

By Bill Thompson | April 11, 2019

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.


Under the terms of this license, you are authorized to share and redistribute the content across various mediums, subject to adherence to the specified conditions: you must provide proper attribution to Stoneridge as the original creator in a manner that does not imply their endorsement of your use, the material is to be utilized solely for non-commercial purposes, and alterations, modifications, or derivative works based on the original material are strictly prohibited.

Responsibility rests with the licensee to ensure that their use of the material does not violate any other rights.

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!