Tinderbox Forum

Setting note display titles from note properties

I have a set of nested notes imported from a CSV export of a nested data structure.
Each note has a ‘name’ property. This name can be either of the form ‘name’ or ‘name.subname’ (or even ‘name.subname.subsuubname’)

On the note prototype, I’ve set the ‘Display Expression’ on the inspector to ‘$truncated_name’. I’ve set the ‘Edict’ for this note prototype to

if($name.contains(’.’)) {
$truncated_name = name.split(’.’).at(-1);
} else {
$truncated_name = $name;

however, it’s failing to set names for notes with a .name containing a full stop character.

I have a suspiction that Tinderbox may be trying to treat ‘.’ as a regular expression, but despite a few attempts at escaping it, I’m not having much luck.

Can anyone see my obvious mistake?

Do you have a $name attribute in addition to the built-in $Name attribute? Case matters in attribute names.

Try (in the if/then/else logic):


You neglected to add $ before name, and you should escape the period in order to avoid the regular expression parsing it as a search token. Yes, .split can take regular expressions. See this.

Thanks Paul, but not joy - I feel the argument to split may or may not be a regular expression rather than a string.

I now have

if($Name.contains('\.')) {
	$truncated_name = $Name.split('\.').at(-1);
} else {
	$truncated_name = $Name;

but it’s no different. Helpfully I have both ‘Name’ and ‘name’ set to the same values, thanks to a helpful CSV import.

I also have Display Expression on the note prototype set to ‘$truncated_name’, which I believe is correct (and will pull out the calculated $truncated_name as the displayed title for the note)

I tested this in a stamp (extracting the core element of your logic):

$truncated_name = $Name.split('\.').at(-1);

and it works correctly.

So there is something else wrong in the overall if-then-else statement. The whole statement does not work in a stamp.


  1. When you have logic issues, then break down the code into smaller pieces (as I did for you, above) and diagnose the pieces.
  2. If you are importing a CSV with a column header name then fix the CSV’s capitalization before importing – it’s easier to do the least laborious fix rather than do the most laborious fix of fixing post-import.
  3. If you use the CSV in Excel, or Numbers, you can do the split of name/Name there a lot faster than in Tinderbox.

Good luck, and stay safe.

1 Like

You’re right: split() interprets its argument as a regular expression, and so you need "\."

I tested this successfully.

This works for me

{$truncated_name = $Name.split("\.").at(-1)} 
else {$truncated_name = $Name}

Eliminated excess spacing. Ran through TextSoap to ensure there are straight quotes and no gremlin characters. Used double quotes. Removed “;”. These last should not matter, but at least the code now works.

Waah! Thanks everyone. At least my code understanding was okay, something else is misfiring.
I took the advice of editing the CSV and re-importing, the coward’s solution. It worked :slight_smile: