How do I get a Content from its UUID in a UFM filter?

I’m trying to create a Custom UFM Filter and I need to get a Content from its UUID. Let’s just say it’s very much related to this question

Inside the filter() method of my class that extends UmbUfmFilterBase I have no idea how to get the Content from the supplied value — I can’t find any examples of how to do this; if anybody knows how it’s done, or can point me to some documentation I’d be very happy!

Thanks!

/Chriztian

@greystate

I don’t think a UFM filter is the right place for this. Filters are synchronous value transformers, so for repository lookups I’d use a custom UFM component that renders a custom element.

In that element you can use UmbDocumentItemRepository.requestItems([unique]). If the value is a UDI from Contentment, convert it first with getGuidFromUdi() from @umbraco-cms/backoffice/utils.

The built-in {umbContentName: pickerAlias} component does something similar, but it expects the value shape it already understands. See the UFM component docs: https://docs.umbraco.com/umbraco-cms/reference/umbraco-flavored-markdown

1 Like

Hi @BishalTimalsina12 :waving_hand:

Thanks a lot - I’ve never understood why there are both “Components” and “Filters”; I bet to the vast majority they’re just two different syntaxes, but your explanation makes sense and I’ll try the component route instead and see where that gets me.

Thanks again :raising_hands:
/Chriztian

1 Like