Skip to content

Filter tasks dynamically based on a list in file properties #3484

Answered by claremacrae
JohannaHerbst asked this question in Q&A
Discussion options

You must be logged in to vote

Solution

Here you go:

filter by function return task.file.property("task-filter-status-view").includes(task.status.name)

Make sure you paste it all on one line, or use Lines Continuations (\) to break the line up.

Assumptions made

  • That the task-filter-status-view property is always provided, and the value is always a list
  • That you really did intend the query to be in the same file as the tasks, and so task.file.property() was the right function, rather than query.file.property()

How it works

It uses Array.includes() to return true of any of the values in the property match the predicate.

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/includes

The…

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
3 replies
@claremacrae
Comment options

Answer selected by JohannaHerbst
@JohannaHerbst
Comment options

@23426356587
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
scope: filters Additions and modifications to the search filters scope: scripting Issues to do with custom filters, custom sorting and similar
3 participants