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?