web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

Dialog field custom lookup on form datasource extension throwing exception

(0) ShareShare
ReportReport
Posted on by 2,724
Hi All,
 
I have developed an extension for the SalesTable form relating to the SalesLine formdatasource.
 
 
Inside this extension I have extended the ValidateDelete method to include a custom dialog where the user must enter some values which will be written into a different table.
 
 
Everything is working ok until I try to override one of the dialog fields to use a custom lookup method.
 
[ExtensionOf(FormDataSourceStr(SalesTable, SalesLine))]
internal final class TSTSalesTableFormSalesLineDs_Extension
{
    /// <summary>
    /// Lookup for deleted sales line reason codes
    /// </summary>
    /// <param name = /_control/>Dialog control</param>
    private void reasonCodeLookup(FormStringControl    _control)
    {
        SysTableLookup          sysTableLookup;
        QueryBuildDataSource    queryBuildDataSource;
        Query                   query = new Query();
        queryBuildDataSource = query.addDataSource(tablenum(TSTSalesLineReasonTable));
        sysTableLookup = SysTableLookup::newParameters(tablenum(TSTSalesLineReasonTable), _control);
        sysTableLookup.addLookupfield(fieldnum(TSTSalesLineReasonTable, TSTSalesCode),  true);
        sysTableLookup.addLookupfield(fieldnum(TSTSalesLineReasonTable, TSTSalesCodeDesc));
        sysTableLookup.parmQuery(query);
        sysTableLookup.performFormLookup();
    }
}
 
The code I am calling from my override is below which calls the custom lookup above - BOTH METHODS ARE IN THE SAME EXTENSION CLASS of the SalesLine form datasource in SalesTable form.
  
 deleteReasonCodeDlg = deleteDlg.addField(extendedTypeStr(TSTSalesCode));
           
 deleteReasonCodeDlg .registerOverrideMethod(methodStr(FormStringControl, lookup),
                methodStr(TSTSalesTableFormSalesLineDs_Extension, reasonCodeLookup),this);
 
The problem when I click on the dialog field when the dialog loads is I get an exception telling me the FormDataSource object doesn't contain the method reasonCodeLookup - but it should as I have added it in the extension of the formDatasource class as above?
 
 
 
 
 
 
What is the best way to accomplish this to ensure the override lookup is called on the dialog in this scenario?
  • Suggested answer
    Layan Jwei Profile Picture
    8,284 Super User 2026 Season 2 on at
    Hi Kauto,
     
    When we use registerOverrideMethod we do it on form level, where we call the registerOverrideMethod inside the init method.
     
    Please check this link to see how to do it
     
     
    Thanks,
    Layan Jweihan
    Please mark this answer as "Verified" if it solved your issue. In order to help others who will face a similar issue in the future
  • Kauto Profile Picture
    2,724 on at
    Hi Layan
     
    So what you are saying is the lookup method should exist in an extension of the SalesTable form's INIT method.
     
    Then I am able to call the registerOverrideMethod to reference it for custom lookup through my other extension which is an extension of the SalesLine data source on the same form?

    You have to understand that I am creating a dialog via the extension so if I create a new extension for the SalesTable form INIT method - I can't reference the dialog field in that code because it won't exist.

    So again - I don't think the below solution will work? I have attempted it and stopped because I know the dialog field won't be able to be found in the INIT method extension because it only gets created in the ValidateDelete extension method
  • Verified answer
    Kauto Profile Picture
    2,724 on at
    I have found a solution myself.
     
    I just created a new class which handled the dialog, custom lookup and return of the collected data.
     
    I then called this class from within my salesLine datasource form code extension and it is working well.
     
    It doesn't look like it is possible to instantiate a dialog class on a form datasource extension and include a custom lookup within the same extension class. 

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 429 Most Valuable Professional

#2
CU10121822-0 Profile Picture

CU10121822-0 366

#3
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 360 Super User 2026 Season 2

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans