PCF-Controls icon indicating copy to clipboard operation
PCF-Controls copied to clipboard

LookupToPicklist does not apply filters added with the addCustomFilter to the lookup control

Open David-Cadmart opened this issue 8 months ago • 4 comments

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.

David-Cadmart avatar May 13 '25 18:05 David-Cadmart

Unfortunately, this is an issue with the PCF framework itself that does not honor the onPreSearch event, as far as I remember.

MscrmTools avatar May 14 '25 16:05 MscrmTools

Oh, that's unfortunate. Are there any known workarounds for this?

David-Cadmart avatar May 14 '25 16:05 David-Cadmart

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?

MscrmTools avatar May 15 '25 08:05 MscrmTools

The only way around it I'm aware of is:

  1. 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>
  2. Add the required number of attributes of various types that your filter will depend on.
  3. 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.

AndrewButenko avatar May 15 '25 17:05 AndrewButenko