Assign $TimelineBand for a current note from a list.at index of another note, based on an attribute of the current note

If you survived the horrific title of this topic, please consider this problem:

  • I have a “projectList” note with a list-type attribute named $project, with content “p1;p2;p3”;

  • I have 3 notes to be plotted on a timeline:

    • “event1” which has “p2” in its $project attribute;
    • “event2” which has “p3” in its $project attribute;
    • “event3” which has “p1” in its $project attribute;
  • the timeline is an agent that collects the three events, and the agent automatically collects as $TimelineBandLabels the terms “p1;p2;p3” from the “projectList” note;

What I am trying to do is to get each event to get its $TimelineBand automatically depending on its $project attribute. So “event1” would get “1”, “event2” would get “2” and “event3” would get “0”.

The logic is each event would lookup its own $project in the $project attribute of the “projectList” and get its value from there. I think it’s the only way to bypass $Timeline Band only accepting numeric values and not strings. I’m trying with collect_if / find / and list/set.at operators, so far with no success.

All help appreciated!

Suggestion: Make a container called /Config/Projects that contains three notes, p1,p2,p3. Each of these notes has a $MyNumber that corresponds to its assigned band. So

$MyNumber(Config/Projects/p1)

is 0.

Then you can have a simple rule for the events

$MyString=“/Config/Project/”+$project;
$TimelineBand=$MyNumber($MyString)

Something like this should work without a collect().

Another possibility is a lookup table. That’s even cleaner. $MyList(/Config).at($project) where $MyList has the value “p1:0;p2;p3:2”

Thank you for the suggestion. I will try the approach, although I don’t know if this is scalable / interactive (I am counting on having several projects being added or removed, or even renamed).

I think I got it in a way it works for me - I’m creating my own task management app inside Tinderbox and one goal is to create projects with stages inside them; each stage will have a planned start date and end date; I then want to visualize all stages in a timeline view, organized by projects (as timeline bands). This worked for me:

- a container for the projects called “projectsList”;

  • inside each project, a variable number of stages with start/end dates;
  • project will get its TimelineBand from its SiblingOrder:
    TimelineBand=$SiblingOrder-1;
  • stage will inherit its TimelineBand from its parent, the project:
    if (!$IsAlias) {$TimelineBand=$TimelineBand(parent);};

- a container for the timeline, which will get its TimelineBandLabels from the ProjectsList:
$TimelineBandLabels=collect_if(children(/projectsList),$Prototype="p_project",$Name);

The result:

timeline-projects-stages.tbx (106.7 KB)

3 Likes

Maybe an edge case but: if you intend to have projects without stages then you must make sure that the timeline will only get its labels from projects with at least one stage. Easy enough, since we can count stages as children of projects. No children > no stages > no timeline label for that project:

$TimelineBandLabels=collect_if(children(/projectsList),$Prototype="p_project" & $ChildCount>0,$Name);