Create a note and then run a link operation on the newly created note

@eastgate, I think this one is for you.

I want to run a stamp against a set. This stamp will perform to operations: 1. create a note for each item in the set, and the 2. link the newly created note to another note.

//Create notes from set
$MySet.each(x){
	var vContainer=$Path;
	var vNote="GAP:"+x;
	create(vContainer,vNote);
};
//Link newly created note to another note.
var x=$Name;
var vFeature="Ftr- "+x;
linkFromOriginal(that)(vFeature,"Gap");

I have step 1 working. What I can’t figure out how to do is have Tinderbox give the newly created note focus to run step 2. Is there a “that” designator syntax that I can use?

Not tested but, don’t overlook that create() returns a note’s path (if successfully created):

//Create notes from set
$MySet.each(x){
	var vContainer=$Path;
	var vNote="GAP:"+x;
	var:list vPathList;
	var vPathList += create(vContainer,vNote);
};
//Link newly created note to another note.
vPathList.each(aPath){
	va:string vFeature="Ftr- "+ $Name;
	linkFromOriginal(aPath,vFeature);
};

Hopefully that get’s moving forwards, though I can’t tell from the second stage what note links to what note.

The problem is that the currently selected note has focus so that link actions linking to that and NOT the newly created now.

OK, the first loop gives yo the paths of the new note(s). Do they linkTo() or linkFrom() another note and if so what is the name of that note. All they all being linked with the same note, or with a different not in each case.

There’s not enough info in the opening description to tell. As a result, my pseudo-code had to make some (wrong!) assumptions. Perhaps a diagram showing the output and link direction might help. Is the new note the target or the destination, etc.?

Here is the process.

  1. I have a note with a bunch of values in a set. I use these value in my Stamp to create children (“that”) from “this” note.
  2. I then want this Stamp to also link each of the newly created children (the “thats”) to a different note note “something else” (the something else is the name of the child with a prefix, it is standard pattern).

So, my problem is, I don’t know how to tell “this” to link “that” to something else.

I’m pretty sure this can be done, but I can’t figure out how to help Tinderbox give the newly create note the focus for the application of the link action.

How are the source and destination related, capturing that is key to the task. You can then use two nested List loops (avoid Sets as you don’t want arbitrary re-sorting or make a dictionary of source as key, destination as value. then you can iterate the dictionary keys and link each source to its destination.

Use createLink, not linkTo and linkFrom.

CreateLink takes two paths, so you don’t need to worry about this.

1 Like

Given the above example the “something else” is the source and the “that” is the destination.

To what are you linking the newly-created notes? Can you construct the path to the destination?

This is fantastic! Works perfectly. Blindingly obviously. Thx.

Here is the stamp I created.

//Create notes from set
$MySet.each(x){
	var vContainer=$Path;
	var vNote="GAP:"+x;
	create(vContainer,vNote);
//Link newly created note to another note.
   var vFeature="Ftr- "+x;
   createLink(vFeature,vNote,"Gap");
};