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:

https://docs.microsoft.com/en-us/powerapps/developer/component-framework/manifest-schema-reference/type

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:

image

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:

image

Here is an example of the web resource:

image

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:

filteredoptions

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!

Leave a Reply

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