Catch frontmatter and inline in same query

What I’m trying to do

I want to write a Dataview query such that it catches an item whether it is in a Property (frontmatter field) or an inline field. (Background: I used to use a meeting notes template with “Participants::” as an inline field. Now I’m using one with a “Participants” property, but using it the same way. In my People template, I’d like to have a single query that shows me meeting notes where that person was a participant, but I don’t want to have to go through all my past meeting notes to change the inline fields to properties.)

Things I have tried

When I include:
where contains(Participants, "[[Manuel Kalpa]]")
the query returns only my old meeting notes where Manuel was listed in the “Participants::” inline field. But if I remove the quotes like:
where contains(Participants, [[Manuel Kalpa]])
I get only my new meeting notes where Manuel was listed in the “Participants” property. I know I can put both in an ‘OR’ configuration, but I’m against this on principal. It seems there should be an easy way to do what I want to do, I just can’t seem to figure it out.

Altenatively, you could

in batch; there’s some way as I recall but where – in what forum thread – I forget. One can search for it.

I don’t believe this is a matter of property versus inline, but rather a matter of either single versus multiple participant declaration, or the field being recognised as links or not.

Do some of your old notes only have one participant, like in: Participants: "[[Manuel Kalpa]]" or even worse: Participants: [[Manuel Kalpa]] ? The latter of these cases is not a link, but a double array with one element at the second level. The first variant could work in some instances, as contains() can to some degree handle simple strings.

Another alternative is that it’s interpreted as the actual string, because if you type "[[Somelink]]" that is actually a string, and not a link. So this could also cause some issues.

So you need to check (or show us) the definitions of Participants in your old&new notes, to verify they’re written in this format:

- "[[As Property]]"

Participants: [[As Inline]]

If you’ve got some of them written as just: Participants: "[[As Single Property]]", you need to do a little trickery related to the contains(), and do something like: contains( flat(list( Participants )), [[Manuel Kelpa]])

That last contains() forces any single and/or list of Participants into becoming a list, allowing for a uniform behaviour of both cases.

Thank you holroy for the helpful information! I’ve modified my query as you suggested, but it behaves the same as what I had before: with quotes it catches the inline and without it catches the properties. In answer to your request, here’s how things have been formatted:

‘Inline’ version (old)
Participants:: [[participant 1]] [[Manuel Kalpa]] [[participant 3]] …

‘Property’ version (new)

  • “[[participant 1]]”
  • “[[Manuel Kalpa]]”
  • “[[participant 3]]”

I recognize I’ve done something wrong, having a naive view of ‘the way things are done’ and I’m hoping to learn from this. I’m willing to do a bulk edit if I have to, but I’d rather not, since I’ve got years worth of notes taken in the old way - not just meeting notes but projects, inputs, etc., and I obviously don’t know what I’m doing here. Thanks for the help!

I think there is no way around it, you need to get your participants defined in a better format. Your current (aka the old) version of doing Participants:: [[a]] [[b]] [[c]] is just a text which happens to contain multiple links, but if you insert a , between those links, dataview would see it as a link and then allow for a better handling in queries.

So I’d very strongly consider doing the bulk edit, and possibly use VS Code to do a search and replace on any lines beginning with “Participants”, and then replace any ]] [[ with ]], [[. Or even better extend that to allow for multiple spaces if that’s a possibility.

A not so good alternative is to try to bully this text into a list of links, but that will look ugly rather quickly:

       "(\[\[[^\]]+\]\])" ),
    (islink) => islink[0] = "[" ),
  (m) => link(substring(m, 2, length(m) - 3)) )

Here we try to extract the parts between the double square brackets, but need to clean it up by eliminating other texts and the surrounding brackets, before we finally map it back into links. Will this catch all of your cases? Most likely not. It doesn’t catch anything related to aliases as it stands. And it’ll not handle non wikilinks, and …

So please, do consider changing your old syntax into something acceptable by dataview and/or other plugins.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.