When p.Activity contains just one value it’s a string, and so includes() checks to see if “[[ABC]]” is in the string – which it is.
But when p.Activity contains multiple values it’s an array, and so includes() checks to see if any array element matches “[[ABC]]” – which it doesn’t (because it’s “#VideoCall [[ABC]]”).
So your where() clause needs to take into account that p.Activity could be a string or an array. What I usually do in this case is force it to be an array using dv.array() and then go from there.
Your new use case adds another possible type for the Activity field, the Link type. A Link is neither a string nor an array, so we have to have additional code to handle this case. Links have properties like path, which is the name of the page.
So now, each time we look at a value for Activity, we’re checking to see if it:
is wrapped in an array (we ensure this using dv.array())
has the includes method (in which case it’s probably a String)
has the path method (in which case it’s probably a Link)
JavaScript isn’t my first language, so likely there’s a more idiomatic way to do this, but it seemed to work in my vault. Here’s what my whole script looks like:
I’ve not tested this, but idiomatic it would be cleaner to do typeof a (maybe soelled incorrectly), to check the type and act accordingly. Or whatever equivalent we’ve got to check the property type.
This time, your code works for me just as far as “ABC” is a not-yet-created note.
If “ABC.md” does exist, at root level, your code works provided I change (a.path && a.path == "ABC") into (a.path && a.path == "ABC.md").
If “ABC.md” is not at root level, I must provide its full path.
Am I doing something wrong?
Where can I find a list of all properties of any given type?