How to extend lookup method and apply query range on the standard MS form X++
Hi folks
In this blog, I am going to explain how lookup control on the standard form can be overridden.
Requirement:
I got the requirement from the customer where in user wants to select Operating unit of type "Department" from the drop down list on the custom fast tab which contains the custom fields on the grid.
Since, Operating units are shared across mutiple legal entities therefore lookup control will display Departments across all companies.
Solution:
Create a class that will handle the logic of overriding the lookup control and applying the range of Operating unit of type "Department" on the lookup. This class is being called on the Form event handler on the lookup control
Form control lookup override extension class:
public class DemoLogisticsPostalAddressFormExtensionOverrides
{
protected void new()
{
}
public static DemoLogisticsPostalAddressFormExtensionOverrides construct()
{
return new DemoLogisticsPostalAddressFormExtensionOverrides();
}
public Common lookupReference(FormReferenceControl _formReferenceControl)
{
return OMOperatingUnitHelper::operatingUnitLookup(_formReferenceControl, OMOperatingUnitType::OMDepartment);
}
public Common resolveReference(FormReferenceControl _formReferenceControl)
{
// Do not call super since we're providing our own disambiguation logic.
return OMOperatingUnitHelper::operatingUnitResolve(_formReferenceControl, OMOperatingUnitType::OMDepartment);
}
}
Form datasource event handler class:
Create a form datasource event handler class for the control on which Departments will be displayed.
Create datasource post event handler initialize method
public class DemoLogisticsPostalAddressFormExtensionOverrides { protected void new() { } public static DemoLogisticsPostalAddressFormExtensionOverrides construct() { return new DemoLogisticsPostalAddressFormExtensionOverrides(); } public Common lookupReference(FormReferenceControl _formReferenceControl) { return OMOperatingUnitHelper::operatingUnitLookup(_formReferenceControl, OMOperatingUnitType::OMDepartment); } public Common resolveReference(FormReferenceControl _formReferenceControl) { // Do not call super since we're providing our own disambiguation logic. return OMOperatingUnitHelper::operatingUnitResolve(_formReferenceControl, OMOperatingUnitType::OMDepartment); } }
*This post is locked for comments