Values for a set attribute in a note

Hello,

I have a note (Note A) with 30 names each following the other after a line break.

I have another note (Note B) with a set attribute called ‘Speaker’.

How can I have the list of names in ‘Note A” become the ‘suggested’ values for ‘Speaker’ attribute in ‘Note B’.

I would appreciate if you could point me towards a tutorial to how to achieve this.

Thank you!

attribute("Speaker") ["suggested"]=$Text("Note A").replace("\n",";");

Note that suggested values are whole-doc scope. so, you can set suggested values only for ‘Note B’.

Notes:

1 Like

@mwra Thqnk you!

The code you kindly shared - where do I enter it?

I had created an attribute called ‘Speaker’ and set it asa set.

Do I enter the code =$Text("Note A").replace("\n",";"); in the box for suggested?

Thank you!

Anywhere! This is because the left side ( the attribute() call) acts at document level so doesn’t care bout the context of the current note/agent: it has the same effect wherever it is run. When testing, I used the Edict of ‘Note B’, but you could use a rule or a stamp or in this case a quickstamp as once run you don’t need the code again.

What you can’t do, via an attribute’s suggested values is to have different suggestions for ‘Note A’ as opposed to ‘Note B’. This is because, as above an attribute’s suggested value work at document level for all notes/agents/etc.

Does that help?

@mwra Thank you! This is very helpful!

1 Like

I’ve just updated Suggest Attribute value lists to clarify that suggested values are per attribute and not per note. These things tend to lay near obvious once you know. :slight_smile:

I added

$Text("Note A").replace("\n",";");

In the document inspector for ‘Note B’ for the attribute ‘Speaker’. Worked beuatifully. It could hand very long list of values, too.

Thank you!

1 Like

Another really good strategy for this is, rather than using the suggested value on an attribute, is to create a resources container, e.g., People. In the people container create notes with the note names being the name for the people. Then, use collect to populate the target attribution, e.g., `$Person=collect(children,$Name)', where $Person is a set attribute. Add this code as a $Rule to your People container. This way, every time you add a new person to this container the name will be available for selection across your Tinderbox file.

Note: I’ve found this methods to be much more flexible and portable across Tinderbox files than messing with suggested. Also, check the our video library we’ve discussed this method in several past meetups.

Graet, thank you @satikusala and @mwra I shall work through them!

2 Likes