LookupToPicklist does not apply filters added with the addCustomFilter to the lookup control
If I add a custom filter to a lookup control in a form via JavaScript using the addCustomFilter function during the onPreSearch event of the lookup attribute, it will be ignored since the onPreSearch event is never triggered.
Unfortunately, this is an issue with the PCF framework itself that does not honor the onPreSearch event, as far as I remember.
Oh, that's unfortunate. Are there any known workarounds for this?
Well, to be more accurate, in the PCF control, we can raise the event onPreSearch but the use on client side of ctrl.SetCustomFilter is not handled in the PCF framework for lookup.
Not sure but do I remember correclty that @AndrewButenko might have a workaround to implement?
The only way around it I'm aware of is:
- Add an additional attribute to the PCF control that will accept the filter that might be parameterised. Something like
<filter><condition attribute="fieldname" operator="eq" value="{placeholder1}"></filter> - Add the required number of attributes of various types that your filter will depend on.
- Inside PCF, on change of filter/values of additional attributes, query the data using the filter and filter the list of records for the dropdown accordingly.