Yes, though explaining it (e.g. with code) makes more sense in the context of specimen data.
FWIW, I attach a small TBX (further below) used to test some ideas above. Iâm, aware you image above suggests youâre working in Map viewâ but for sake of clarity this task is much easier to do/test in outline view, even if you work on the outcome in map view. Here what the demo looks like.
Iâm assuming weâre marking notes of interest in a user attribute. Iâve used a String ($Topic) and an alternate Set ($Topics) just to show the idea. Depending on which you use (String or Set) a slightly different query syntax is needed. In your own work you can name the attribute as you choose.
The âagent testing stringâ takes thins one step further as the search target is parameterised. Thus instead of coding âTariffsâ into the query, the query uses the value ($MyString) of the agentâs attribute âMyStringâ.
The agentâs edict is then:
var:string vString;
vString = collect(children,$Text).format("\n");
var:string vPath = "/Topics/"+$MyString;
$Text(vPath) = vString;
The data is written to note /Topics/Trade
, though if working on a map you might want to forego the use of the âTopicsâ container although it helps for testing (as the map might have 100s of notes and finding the new one to check can take a moment).
Were you wanting to build the note on the fly @eastgateâs post above, indicates the rough pattern. Note that create()
wonât make the same note twice, i.e. if it already exists.
The second agent just shows the different query yo use if searching a Set or List type attribute.
The âNote using edictâ forgoes the agent and does the querying within the note. Again the edict is used to populate the target note:
var:string vString;
vString = collect(find($Topic==$MyString(that)&!$IsAlias),$Text).format("\n");
var:string vPath = "/Topics/"+$MyString;
$Text(vPath) = vString;
The result is in note âTradeâ. Though for a different topic and via a different collection method not the $Text of âTariffsâ and of âTradeâ is essentially similar.
Yes, I added a new edit note to the demo âNote using edict with text headingsâ which populates note âTradeâwith headingâ via the following edict:
var:list vList;
// we add to target name to avoid other demo
var:string vPath = "/Topics/"+$MyString+"âwith headings";
vList = find($Topic==$MyString(that)&!$IsAlias);
var:string vString=;
vList.each(aNote){
vString+="Text from note at path: "+aNote+"\n";
vString+=$Text(aNote)+"\n";
vString+="~~~~~~~~~~\n\n";
};
$Text(vPath) = vString;
Note that to add the per-source note headings a slightly different approach is needed. This reflects the guidance in my first answer and in @eastgateâs answer that you decide the structure. So there is no notion of a âheadingâ. But, if you want to insert text into the output yet which is not derived from the (being processed) source noteâs body text this is possible. As this additional test shows.
You might also ask yourself: do I need all this?. For instance, in the demo, if you select all the aliases and look at the text pane to you see:
Now you know that it might be enough. However, only you can tell that. This is why advice here may often seem loose-edged. Fellow users here can only respond to the information provided, which (innocently) may not be the full picture. Then again, the âfull pictureâ can be an emergent property, i.e. as you dig in the picture slowly emerges. It also explains why building to much, too early in terms of process, often means a do-over unless one is re-running the exact same scenario as before.
If templated to ask âCan I have the heading formattedâ, as in ârich textâ bold/italic etc. It is possible but not productive. Iâd ask myself do I truly need it or think so just because I imagined it might be so based on working in WYSIYG word processors. If you want text formatting you may do well to consider the preview approach alluded to in a previous answer.
HTH 
Edit: Forgot to add the demo tbx
Here is the demo file: collecting-text-1.tbx (159.6 KB). NOTE: there is no âreadmeâ as the TBX is explained above. Writing a fully documented demo would take more time than is spare at present!
â . If so, and for reasons not to dive into here, there are significant upsides to not building your main map at root level. If you have done this it is easy to make a new note that with be the map container. Then select only the items you donât want/need on the map (e.g. not /Hints
, /Templates
, etc.) then drag the selection onto your new note. the drop moves all the selected item to the child map of the new container.