Tinderbox Forum

Creating a new note with action code

I don’t know what’s wrong with my action code. It looks like this:
create("Quotes from" + $Name(parent));
but after applying it to a note, what I get is a child note with the $Name:
"Quotes from" + $Name(parent)
what I want is (for example):
Quotes from @Lapid1989a

Any ideas?

Sometimes you need to compile operator inputs before use. I made a stamp, to be used on the note that will become the parent of the new note:

var vPath = "Quotes from " + $Name;

Note the extra trailing space on the literal string.

Whether you actually need $Name(parent) as opposed to $Name likely is a detail to resolve, but don’t forget you apply this to an existing note that becomes the parent of the new note. In that case, using $Name(parent) would give you a result like this:

Here’s my test: create-test.tbx (80.8 KB)

1 Like

Works perfectly!

I haven’t thought about it…

Thanks for the swift reply!

Great! The reason I use a variable is vPath is once the code has run, vPath is not kept. Before the var var operator we would need to use an attribute to store the creation path, e.g.

$MyString  = "Quotes from " + $Name;
$MyString =;  // clean out stored value

That makes it all the more logical-seeming that you might—as in your opening question—build the path string in the create() input argument.

Don’t forget that if create() is successful it returns the $Path of the new note, which you can capture in an attribute or variable and then use it to do something with that note. Here, we us a second variable to hold the path and use it to set the $Badge of the new note:

Code for the above stamp:

var vPath = "Quotes from " + $Name;
var vNotePath = create(vPath);
$Badge(vNotePath) = "quote";
1 Like

Thank you for explanation! :wink:

1 Like