Whenever we have a Meeting, we also want to have Tasks connected to it. So we can add it directly in the Tasks view (image). And to make it automatically connected to the Meeting’s Project we can set up a Global filter. But this effects all other Projects as well. So I thought, can I filter by [This Meeting].Project instead, so it’s automatically connected to the right Project?
What do you mean by the ‘Tasks connected to it’?
Based on how you have described your relations
a Task could be linked directly to a Meeting (many-to-many), but can also be inferred as being related to a Meeting because it shares the same parent Project.
If you want to show the Tasks indirectly related to the Meeting, you could create a lookup, but this would be a read-only field.
The Tasks field you are showing in the image above represents the direct relation by default.
If you want to change the relation view to be context filtered to show indirectly related Tasks (= those Tasks owned by the Project that the Meeting is owned by) then it is not possible for the reasons explained here:
Well, I would take a step back and ask the question: what is the meaning of having two relations between Task and Project (one direct and one indirect)?
Can a Task belong to a Meeting but not belong to the Project that the Meeting relates to?
Can a Task belong to a Project but not belong to all the Project’s Meetings?
What is the flow for users in terms of when/how Tasks are created?
TLDR
A simple way to create Tasks within a Meeting, that is automatically associated to a Project.
Description
Can a Task belong to a Meeting but not belong to the Project that the Meeting relates to?
Yes (in practice right now). But we would like a Task to always be connected to a Project. So this is done manually right now (if it’s created in a view that does not set the Project at creation).
Can a Task belong to a Project but not belong to all the Project’s Meetings?
Yes.
What is the flow for users in terms of when/how Tasks are created?
Basically one of these:
Within a Project, create a Task. E.g within the Project “Clean the office” have the Tasks “Clean windows”, “Clean floor”, e.t.c.
Within a Meeting (that is connected to a Project), create action items (Tasks). E.g. within the Meeting “Review of office cleaning” have the Tasks “Clean windows again, missed a spot”
I have already made a button within a Meeting that automatically sets the Project based on the Meeting’s related Project. And it works fine.
But if you look at the first image in this thread I’m looking for a way to create a Task from the Task relation view and have it set the Project automatically.
But do you think it would be possible to do what you suggest?
Basically, I’m asking this for my team members. I know of the limitations that currently exist and can go to the button whenever I want to create a Task from a Meeting. But since the software allows for creation of tasks from many different places and it says “Link or Create” you expect the Task to be connected to the Meeting’s Project as well.
This will be triggered if a Task is created in a Meeting’s relation field (since the Task is effectively being linked to the Meeting immediately on creation).
It will link the Task to the Project that the Meeting belongs to.
But note, if you were to move a Task from one Meeting to another, and the second Meeting belonged to a different Project, the Task would be switched from the first Meeting’s Project to the second’s.
I guess this may not happen very often, but you need to think if this is the behaviour you want.
There is basically no easy fix for this issue, since the current database relations allow for a Task to be linked to multiple Meetings, and yet these Meetings might not belong to the same Project.
Yeah, that is one way of ensuring that a Task doesn’t accidentally change Project if it is added to another Meeting.
But still begs the question of how to resolve if a Task is linked to multiple Meetings each with a different parent Project…
Hopefully, it is a largely theoretical question
FYI it’s also possible when creating an inline entity in a Rich Text field (via Ctrl/Cmd+E) to automatically link the new entity to the one you are working within (i.e. the entity containing the Rich Text) or some other related entity.
This does require some more complex scripting though:
// If a Task's "Project" field is uninitialized, and there is a "Meeting Notes"
// that references the Task, set the Task's "Project" field from the MN's "Default Project".
// Script parameters
const ENTITY_LINK_FIELD = 'Project' // Task field that needs to be set
const PARENT_TYPE = 'Project/Project' // Type we want to find a link to (value for)
const REF_ENTITY_TYPES = ['Clients/Meeting Notes'] // Types that have a "Default Project" field
const REF_ENTITY_LINK_FIELD = 'Default Project' // Name of the field to copy
const fibery = context.getService('fibery')
// const log = console.log
for (const entity of args.currentEntities) {
// Set the Project field only if empty
if (entity[ENTITY_LINK_FIELD].id !== null) { continue }
// Get all references to the Task
const entityWithRefs = await fibery.getEntityById(entity.type, entity.id, ['References'])
// Look for a reference to a type with a "Default Project" field (i.e. Meeting Notes)
for (const ref of entityWithRefs['References']) {
// Get referencing doc
const refDoc = await fibery.getEntityById('Collaboration~Documents/Reference', ref['Id'], ['FromEntityId', 'FromEntityType'])
const refType = refDoc['FromEntityType'].name
if (refType == PARENT_TYPE) {
// The referring entity is the actual PARENT_TYPE (so its ID can be used directly)
// I.e. a Task was created/referenced in a Project's Rich Text field, so we know the Project
const refEntity = await fibery.getEntityById(refType, refDoc['FromEntityId'], ['Name'])
// log(` refType == PARENT_TYPE: ${refType}, ${refDoc['FromEntityId']} ${refEntity.id}`)
await fibery.updateEntity(entity.type, entity.id, { [ENTITY_LINK_FIELD]: refEntity.id })
break
} else if (REF_ENTITY_TYPES.includes(refType)) {
// Found a suitable referring entity (i.e. that has a "Default Project" field)
const refEntity = await fibery.getEntityById(refType, refDoc['FromEntityId'], ['Name', REF_ENTITY_LINK_FIELD])
if (refEntity != null && refEntity[REF_ENTITY_LINK_FIELD].id != null) {
const refId = refEntity[REF_ENTITY_LINK_FIELD].id
await fibery.updateEntity(entity.type, entity.id, { [ENTITY_LINK_FIELD]: refId })
break
}
}
}
}