Adding FetchXml filtering to the N:N lookup

By | February 29, 2020

I was looking into adding FetchXml parameter to the N:N lookup PCF component earlier today, and something interesting came up.

But first things first. I needed a way to define a filter for the list of records my control will be showing in the dropdown list. Imagine the following scenario, for instance:

  • There is a long list of tags
  • However, for every N:N lookup I want to be able to choose from a subset of tags rather than from the whole list


“No problem – let’s just use FetchXml”. Or, at least, so I thought.

It seems we should be able to create multiline properties for our PCF controls – if you look at the manifest schema reference, you’ll see “Multiple” and “SingleLine.Text” types there:

I tried both, but, somehow, for either of them I could only use a certain number of characters into the property value(not sure how many exactly, but it was not even 200) . On the screenshot below, it’s been cut off at around 160th character:


Well, maybe it just does not work, or, maybe, I don’t know how to use it.

In either case, I figured if it’s limited that way then I need something else, so, in the end, here is how it worked out:

  • Instead of accepting FetchXml as a parameter, N:N lookup will be accepting a web resource name
  • FetchXml will have to be stored in that web resource


Here is an example of the control property:


Here is an example of the web resource:


And you will see below how the values are getting filtered (only those having “1” in the name are displayed in one of the controls) when there is FetchXml filter:


If you know of a better way to create multiline parameters, please drop me a note – would be much appreciated. In either case, those changes are in the github repo now, so feel free to try it out!

3 thoughts on “Adding FetchXml filtering to the N:N lookup

  1. Niels Minnee

    Hi! You can use the multi in pcf, the only thing is that the current gui of the custom control properties is limiting you with 100char. It’s a bit of a hack but when you use the browsers developers tool you can change it from 100char to something else and then paste your filter. See my version of NNdropdown at github and/or PCF gallery.

  2. Todd Schopp

    Have you found any way to return more than 5000 records when using the FetchXML filter?

  3. Todd Schopp

    Hi Alex,
    My requirement is to be able to change the filtering dynamically. I don’t think that’s possible with the FetchXML in a web resource. Nor do I think it’s possible with your original idea of putting the FetchXML into the settings field, if it was long enough. But I’ve seen another control with a setting for the name of another field on the form that contains the FetchXML. If you added that capability, then that field’s value could be modified dynamically and the filtering changed dynamically. What do you think?


Leave a Reply

Your email address will not be published. Required fields are marked *