Using queries in metadata

I’m trying to create a metadata field ‘M1’ based on matching metadata in the current file ‘M2’ and ‘M3’ with the same metadatavariables in files tagged with T1.

This line of code does this;

M1:: `$=dv.pages('#T1').where(p=> p.M2= dv.current().M2 && p.M3== dv.current().M3)`

This works fine, and the M1-field is filled with comma-seperated links, as expected.

However, when querying for these files, and trying to access this field with simple dataview code, it returns ‘’. It seems as if it doesn’t get the list inserted by the code, but that it returns the line of code, and thus tries to look for files whereas the M2 and M3 matches the file where the simple dataview query is made.

Does anyone have any idea about how i could fix this?

Dataview queries are by nature dynamic, and will not store easily into another field.

To convert into something static you need to use the query within a template where you store the result, and not the query.

Or you need to extend the query to do an edit and save its result into the file somehow. It can be done, but there are some caveats related to race conditions and other mechanics.

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