Getting a List from MetaData Menu Object List in Dataview JS Table

What I’m trying to do

Using MetaData Menu, I have a Class called ‘Project’ and, in that I want to have some sort of a ‘repeater’ field that I can add the most urgent tasks to so that I can see and ‘at a glance’ overview of where I am with the projects I am responsible for. This overview uses DataviewJS to list the projects, the urgency and, the bit I am struggling with, the most urgent 3 tasks I need to work on for each project, listed in one cell.

Here’s a screenshot of what I am aiming for using manually coded lists where I want those most urgent 3 tasks to appear (either numbered or not, that doesn’t matter):

So far I think I’ve spent about 6 hours trying to figure this out plus rewatching videos.

Things I have tried

Having watched a bunch of videos I have yet to find an explanation about how to use the items in one of MetaData Menu’s ‘Object’ or ‘ObjectList’ fields so I am struggling to get what I am aiming for.

This is my Class set-up with ObjectList:

I attempted to get the 3 tasks to appear using all combinations of dv,p, “uTasks” I could think of but I could not get all 3 to appear. Which is why I am only using a single field in there at the moment and using a manually created list.

If I use f(dv,p, "uTasks"), instead of f(dv,p, "uTasks.uTask1"), I get
04-Query2

So, at the moment, I am manually entering a list into Task1.

Is there an explanation anywhere that I can follow that would show me how to do this or is it a simple bit of code I need adding?

Thank you for reading.

Martin

I don’t have a setup like yours, so this is untested, but are you able to do:

[ await f(dv, p, "uTasks.uTask1"), await f(dv, p, "uTasks.uTask2"), await f(dv, p, "uTasks.uTask3") ]

Instead of your current await f(dv, p, "uTasks.uTask1")?

Or a similar approach when using uTasks to map each entry into a new array within the array of the other columns?

That does give me the outputs but in 3 separate cells, creating additional columns in the table rather than listing all 3 in the same table cell.

Does that make sense?

Hmmm… extra columns? With this syntax it should give a list in one column.

.map(async p => [
  p.file.link,
  await f(dv, p, "status), 
  [ await f(dv, p, "uTasks.uTask1"), await f(dv, p, "uTasks.uTask2"), await f(dv, p, "uTasks.uTask3") ] ,
  await f(dv, p, "urgencyRating")])

That did work. I think I must have copied it wrong the first time.
Thank you so much.

Is it possible to only render the uTasks that are not empty?
Obviously, uTask1 will always be populated but uTask2 and uTask3 might be empty.

Thanks again for your knowledge.

This is what I have now:

const {fieldModifier: f} = this.app.plugins.plugins["metadata-menu"].api;

dv.table(["Project", "Status", "Next Tasks", "Urgency Rating"],
await Promise.all(dv.pages('"Projects/Project Files"').sort(p => p.UrgencyRating, "desc").map(async p => [
	p.file.link,
	await f(dv,p, "Status"),
	[await f(dv, p, "uTasks.uTask1"), await f(dv, p, "uTasks.uTask2"), await f(dv, p, "uTasks.uTask3")],
	await f(dv,p, "UrgencyRating")])
))

Martin

Maybe do some terniary operation? p.utask.utask1 ? await f( ... ) : ""

Not entirely sure on the syntax since I don’t have a good enough image of your setup.

This is my JS so far (thanks to your help):

const {fieldModifier: f} = this.app.plugins.plugins["metadata-menu"].api;

dv.table(["Project", "Status", "Next Tasks", "Urgency Rating"],
await Promise.all(dv.pages('"Projects/Project Files"').sort(p => p.UrgencyRating, "desc").map(async p => [
	p.file.link,
	await f(dv,p, "Status"),
	[await f(dv, p, "uTasks.uTask1"), await f(dv, p, "uTasks.uTask2"), await f(dv, p, "uTasks.uTask3")],
	await f(dv,p, "UrgencyRating")])
))

I need to get an ‘IF’ in there so empty Tasks are not rendered.

In this line, I need to get rid of empty tasks
await f(dv, p, “uTasks.uTask1”), await f(dv, p, “uTasks.uTask2”), await f(dv, p, “uTasks.uTask3”)

In my mind (where there is very little knowlegde of JS), this is my thinking:

if (uTasks.uTask1 is !null
await f(dv, p, “uTasks.uTask1”)),

And then uTask2 and uTask3.

Please excuse the simplicity of my thinking.

Martin

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