Links generated in Reports are not opening the correct note

As background, I have been duplicating notes, so that the note title has the same name, but the date field is different and it is appended to the file name to generate unique file names.

Note ID Configuration

Note Identifier Rule: title before auxiliary field

Text ID Rule: title before auxiliary field

Auxiliary Field: Work Record Date

Text ID Separator: on

Further background. I’ve just started experimenting with folders and all of the notes I’m discussing here have been moved into a folder.

In the report the link to the note is generated using <a href="notenik://open?shortcut=workrecords&id==$title&i$=">=$title$=</a></td>. For all the duplicated notes, the URL generated is identical.

Q . How should we generate ID links to match the note ID config?

Issue: When clicking on links, even links which are unique within the collection, the correct note is not being displayed. Notenik is coming to the foreground. It’s not displaying one of the set of notes that might match the ID, it just seems to display the note active at the time the link is used.

When working from the command line to pass the URL I get this output in the log:

Received an Apple Event
Apple Event passed URL: notenik://open?shortcut=workrecords&id=acquireassetsandassessthem
Initializing Collection
Collection: /Users/malcolm/Library/Mobile Documents/iCloud~com~powersurgepub~notenik~shared/Documents/WorkRecords
4 Notes loaded from the sub-folder
Note titled 'Test with PHP Call' appears to be a duplicate and could not be accessed
4 Notes loaded from the sub-folder
130 Notes loaded for the Collection
Preferred Note File Format Presumed to be notenik
Duplicates found within the Collection folder -- see Log for details
Note could not be found with this ID: acquireassetsandassessthem

A note titled “Acquire assets and assess them” is present, and it’s a unique title.

I think you’ve found a hole in my implementation of variable Note ID configurations. I’ve tried to plug the hole with the latest beta by adding a new merge template derived variable of Unique ID for Note which should pull in the correct identifier for the note. If you could test this and let me know how it works, I’d be appreciative!

:frowning_face:

I’m seeing the same behaviour. The correct collection is opened but the note is not.

Sorry about that. I see one more thing that needs doing. I’ll have a fix in the next beta.

Perhaps related: For Notes with a NoteID that differs from the Title, I see that the link in a Script Output from a query seems to use the TextId/Title only and therefore doesn’t open correctly while copying the Notenik URL of a note from the Note selector menu or the Ctrl-click menu does correctly copy the URL with the NoteID.

Check the latest beta when you get a chance. Hopefully this issue will be fixed. Thanks!

No luck for me. The collection is throwing a “duplicate” error. I’m attaching the log for you.

iCloud Notenik Documents container available at /Users/malcolm/Library/Mobile Documents/iCloud~com~powersurgepub~notenik~shared/Documents exists? true
Initializing Collection
Collection: /Users/malcolm/Library/Mobile Documents/iCloud~com~powersurgepub~notenik~shared/Documents/ToDoList
Display Template will be formatted using CSS file named display.css
8 Notes loaded for the Collection
Loaded 2 alias entries from alias.txt
Preferred Note File Format Presumed to be notenik
Initializing Collection
Collection: /Users/malcolm/Library/Mobile Documents/iCloud~com~powersurgepub~notenik~shared/Documents/ToDoList
Initializing Collection
Collection: /Users/malcolm/Library/Mobile Documents/iCloud~com~powersurgepub~notenik~shared/Documents/Miscellany
Initializing Collection
Collection: /Users/malcolm/Library/Mobile Documents/iCloud~com~powersurgepub~notenik~shared/Documents/Clients
Initializing Collection
Collection: /Users/malcolm/Library/Mobile Documents/iCloud~com~powersurgepub~notenik~shared/Documents/PoupouHuiaTeReo
Initializing Collection
Collection: /Users/malcolm/Library/Mobile Documents/iCloud~com~powersurgepub~notenik~shared/Documents/FileMaker/notes
Initializing Collection
Collection: /Users/malcolm/Library/Mobile Documents/iCloud~com~powersurgepub~notenik~shared/Documents/Intro
Initializing Collection
Collection: /Users/malcolm/Library/Mobile Documents/iCloud~com~powersurgepub~notenik~shared/Documents/Test/resources
Initializing Collection
Collection: /Users/malcolm/Library/Mobile Documents/iCloud~com~powersurgepub~notenik~shared/Documents/Test/content
Initializing Collection
Collection: /Users/malcolm/Library/Mobile Documents/iCloud~com~powersurgepub~notenik~shared/Documents/XPath
Initializing Collection
Collection: /Users/malcolm/Library/Mobile Documents/iCloud~com~powersurgepub~notenik~shared/Documents/FMSoup Data Retention Policy
Initializing Collection
Collection: /Users/malcolm/Library/Mobile Documents/iCloud~com~powersurgepub~notenik~shared/Documents/HamiltonMove
Initializing Collection
Collection: /Users/malcolm/Library/Mobile Documents/iCloud~com~powersurgepub~notenik~shared/Documents/Commonplace/author-works/author-notes
Initializing Collection
Collection: /Users/malcolm/Library/Mobile Documents/iCloud~com~powersurgepub~notenik~shared/Documents/Commonplace/author-works
Initializing Collection
Collection: /Users/malcolm/Library/Mobile Documents/iCloud~com~powersurgepub~notenik~shared/Documents/Commonplace
Initializing Collection
Collection: /Users/malcolm/Library/Mobile Documents/iCloud~com~powersurgepub~notenik~shared/Documents/TheFMSoup
Initializing Collection
Collection: /Users/malcolm/Library/Mobile Documents/iCloud~com~powersurgepub~notenik~shared/Documents/CodeSnippets
Initializing Collection
Collection: /Users/malcolm/Library/Mobile Documents/iCloud~com~powersurgepub~notenik~shared/Documents/ToDoList
Initializing Collection
Collection: /Users/malcolm/Library/Mobile Documents/iCloud~com~powersurgepub~notenik~shared/Documents/Home NoGood
Initializing Collection
Collection: /Users/malcolm/Library/Mobile Documents/iCloud~com~powersurgepub~notenik~shared/Documents/Dispute Tribunal - Hamilton Movers
Initializing Collection
Collection: /Users/malcolm/Library/Mobile Documents/iCloud~com~powersurgepub~notenik~shared/Documents/WorkRecords/Certificate Ordering Button
Initializing Collection
Collection: /Users/malcolm/Library/Mobile Documents/iCloud~com~powersurgepub~notenik~shared/Documents/WorkRecords
Initializing Collection
Collection: /Users/malcolm/Library/Mobile Documents/iCloud~com~powersurgepub~notenik~shared/Documents/WorkRecords/Action Station 2024
Initializing Collection
Collection: /Users/malcolm/Library/Mobile Documents/iCloud~com~powersurgepub~notenik~shared/Documents/Rārangi Kupu Māori
Initializing Collection
Collection: /Users/malcolm/Library/Mobile Documents/iCloud~com~powersurgepub~notenik~shared/Documents/Jobs
Initializing Collection
Collection: /Users/malcolm/Library/Mobile Documents/iCloud~com~powersurgepub~notenik~shared/Documents/KadimaWorkNotes
Initializing Collection
Collection: /Users/malcolm/Library/Mobile Documents/iCloud~com~powersurgepub~notenik~shared/Documents/App Catalog
Initializing Collection
Collection: /Users/malcolm/Library/Mobile Documents/iCloud~com~powersurgepub~notenik~shared/Documents/Internet Favorites
Initializing Collection
Collection: /Users/malcolm/Library/Mobile Documents/iCloud~com~powersurgepub~notenik~shared/Documents/What  a Website/resources
Initializing Collection
Collection: /Users/malcolm/Library/Mobile Documents/iCloud~com~powersurgepub~notenik~shared/Documents/What  a Website/content
Initializing Collection
Collection: /Users/malcolm/Library/Mobile Documents/iCloud~com~powersurgepub~notenik~shared/Documents/CleanTest
Initializing Collection
Collection: /Users/malcolm/Library/Mobile Documents/iCloud~com~powersurgepub~notenik~shared/Documents/Home Search
Initializing Collection
Collection: /Users/malcolm/Library/Mobile Documents/iCloud~com~powersurgepub~notenik~shared/Documents/Clients
11 Notes loaded for the Collection
Preferred Note File Format Presumed to be notenik
Populating 2 lookbacks for Collection identified as clients
Lookbacks requested for collection ID of jobticket
Initializing Collection
Collection: /Users/malcolm/Library/Mobile Documents/iCloud~com~powersurgepub~notenik~shared/Documents/Jobs
Display Template will be formatted using CSS file named display.css
14 Notes loaded for the Collection
Loaded 22 alias entries from alias.txt
Preferred Note File Format Presumed to be notenik
Lookbacks requested for collection ID of todolist
Populating 1 lookbacks for Collection identified as jobticket
Lookbacks requested for collection ID of workrecords
Initializing Collection
Collection: /Users/malcolm/Library/Mobile Documents/iCloud~com~powersurgepub~notenik~shared/Documents/WorkRecords/Action Station 2024
5 Notes loaded for the Collection
Preferred Note File Format Presumed to be notenik
Saved 2 alias entries to alias.txt
Loading Shortcut of clients with path of file:///Users/malcolm/Library/Mobile%20Documents/iCloud~com~powersurgepub~notenik~shared/Documents/Clients/
Loading Shortcut of quotes with path of file:///Users/malcolm/Library/Mobile%20Documents/iCloud~com~powersurgepub~notenik~shared/Documents/Commonplace/
Loading Shortcut of qworks with path of file:///Users/malcolm/Library/Mobile%20Documents/iCloud~com~powersurgepub~notenik~shared/Documents/Commonplace/author-works/
Loading Shortcut of qauthors with path of file:///Users/malcolm/Library/Mobile%20Documents/iCloud~com~powersurgepub~notenik~shared/Documents/Commonplace/author-works/author-notes/
Loading Shortcut of jobticket with path of file:///Users/malcolm/Library/Mobile%20Documents/iCloud~com~powersurgepub~notenik~shared/Documents/Jobs/
Loading Shortcut of kadimaworknotes with path of file:///Users/malcolm/Library/Mobile%20Documents/iCloud~com~powersurgepub~notenik~shared/Documents/KadimaWorkNotes/
Loading Shortcut of todolist with path of file:///Users/malcolm/Library/Mobile%20Documents/iCloud~com~powersurgepub~notenik~shared/Documents/ToDoList/
Loading Shortcut of workrecords with path of file:///Users/malcolm/Library/Mobile%20Documents/iCloud~com~powersurgepub~notenik~shared/Documents/WorkRecords/
Loading Shortcut of workrecords with path of file:///Users/malcolm/Library/Mobile%20Documents/iCloud~com~powersurgepub~notenik~shared/Documents/WorkRecords/Action%20Station%202024/
Loading Shortcut of workrecords with path of file:///Users/malcolm/Library/Mobile%20Documents/iCloud~com~powersurgepub~notenik~shared/Documents/WorkRecords/Certificate%20Ordering%20Button/
Initializing Collection
Collection: /Users/malcolm/Library/Mobile Documents/iCloud~com~powersurgepub~notenik~shared/Documents/WorkRecords
4 Notes loaded from the sub-folder
Note titled 'Test with PHP Call' appears to be a duplicate and could not be accessed
4 Notes loaded from the sub-folder
130 Notes loaded for the Collection
Preferred Note File Format Presumed to be notenik
Duplicates found within the Collection folder -- see Log for details
Starting to play script located at /Users/malcolm/Library/Mobile Documents/iCloud~com~powersurgepub~notenik~shared/Documents/WorkRecords/reports/Certificate Ordering Button_script.tcz on 18/04/2024 at 8:28:58 PM
Setting maximum directory depth to 1
Initializing Collection
Collection: /Users/malcolm/Library/Mobile Documents/iCloud~com~powersurgepub~notenik~shared/Documents/WorkRecords
4 Notes loaded from the sub-folder
Note titled 'Test with PHP Call' appears to be a duplicate and could not be accessed
4 Notes loaded from the sub-folder
130 Notes loaded for the Collection
Preferred Note File Format Presumed to be notenik
130 rows read from /Users/malcolm/Library/Mobile Documents/iCloud~com~powersurgepub~notenik~shared/Documents/WorkRecords
Creating filter rule: Ticket eq Certificate Ordering Button
5 Notes passed the filter rules
125 Notes were filtered out
Creating sort field: Work Record Date ascending
2 output files written
0 output files with no changes
408 lines read from template file
Script execution complete on 18/04/2024 at 8:28:59 PM
Received an Apple Event
Apple Event passed URL: notenik://open?shortcut=workrecords&id=acquireassetsandassessthem
Note could not be found with this ID: acquireassetsandassessthem
Received an Apple Event
Apple Event passed URL: notenik://open?shortcut=workrecords&id=searchhaslostitssearch
Note could not be found with this ID: searchhaslostitssearch
Initializing Collection
Collection: /Applications/Notenik.app/Contents/Resources/NotenikDocs/knowledge-base
2 Attachments loaded for the Collection
2 Class Template(s) Loaded from the class folder
507 Notes loaded for the Collection
Loaded 572 alias entries from alias.txt
Preferred Note File Format Presumed to be notenik
Could not write html to temporary file
Could not write html to temporary file
Could not write html to temporary file
Could not write html to temporary file
Could not write html to temporary file
Could not write html to temporary file
Could not write html to temporary file
Could not write html to temporary file
Could not write html to temporary file
Could not write html to temporary file
Could not write html to temporary file
Could not write html to temporary file
Could not write html to temporary file
Could not write html to temporary file
Could not write html to temporary file
Could not write html to temporary file
Starting to play script located at /Users/malcolm/Library/Mobile Documents/iCloud~com~powersurgepub~notenik~shared/Documents/WorkRecords/reports/Certificate Ordering Button_script.tcz on 18/04/2024 at 8:35:49 PM
Setting maximum directory depth to 1
Initializing Collection
Collection: /Users/malcolm/Library/Mobile Documents/iCloud~com~powersurgepub~notenik~shared/Documents/WorkRecords
4 Notes loaded from the sub-folder
Note titled 'Test with PHP Call' appears to be a duplicate and could not be accessed
4 Notes loaded from the sub-folder
130 Notes loaded for the Collection
Preferred Note File Format Presumed to be notenik
130 rows read from /Users/malcolm/Library/Mobile Documents/iCloud~com~powersurgepub~notenik~shared/Documents/WorkRecords
Creating filter rule: Ticket eq Certificate Ordering Button
5 Notes passed the filter rules
125 Notes were filtered out
Creating sort field: Work Record Date ascending
2 output files written
0 output files with no changes
408 lines read from template file
Script execution complete on 18/04/2024 at 8:35:50 PM
Received an Apple Event
Apple Event passed URL: notenik://open?shortcut=workrecords&id=testwithphpcall
Note could not be found with this ID: testwithphpcall
Received an Apple Event
Apple Event passed URL: notenik://open?shortcut=workrecords&id=testwithphpcall
Note could not be found with this ID: testwithphpcall
Received an Apple Event
Apple Event passed URL: notenik://open?shortcut=workrecords&id=searchhaslostitssearch
Note could not be found with this ID: searchhaslostitssearch

There’s a lot going on here!

@Malcolm, any chance you could zip up all the related collections and scripts, etc., and email the zip file to me at hbowie@fastmail.fm?

I would of course delete everything after completing debugging and testing.

I’m not able to replicate any issues based on the info I have available.

Thanks for sending along your files, @Malcolm. Very helpful!

I found three issues.

  1. You have several different notes with the title ‘Test with PHP Call`. Two of them have different dates, but another one shares the same date with another so, even though it’s in a different folder, it counts as a duplicate. If you opened each separate folder on its own, they would all load correctly, but when you try to load the parent with subfolders, the duplicate keys causes one to be ignored.

    This is clearly a case where, even though the file paths are different, the internal keys are the same.

    I could see an argument being made for changing this so that a sub-folder is always included as part of a note’s internal key, but then another problem might arise: if you moved a Note from one folder to another, then any links to that note from other notes would break.

  2. In your file named Certificate Ordering Button_template.html, you will need to use a text editor to change &id==$title&i$= to &id==$Unique-ID-for-Note&i$=. This should then cause the links in this report to open the correct Notes when it is run. (At least it did the trick in my testing.)

  3. I did find a case where the Note ID configuration for the parent folder could end up set differently than the Note ID configuration for a subfolder. This was not actually causing a problem in your case, but I modified the Notenik code so that this could not accidentally happen to others.

Hope this helps!

Great. That was a useful exercise. After removing the unwanted duplicate file and making changes to the template everything is working.

:smiley_cat:

Background: The duplicate file would have got into the other folder as a result of my experimenting.

The first thing I did - newbie error - was to use BBEdit to insert "folder: " & the client reference into each note. My mistaken assumption was that this would auto-magically generate folders for all of the notes without me having to edit each note separately. After that didn’t work, I read the knowledge base and discovered that I’d need to use Notenik in edit mode to manage that process. In hindsight I assume that I could simply have created the folders in Finder and dragged the notes into them, edited the template to include the folder field, and then the auto-magic would kick in.

I opened these notes in Notenik and experienced problems with creating folders, then with switching a note from one folder to another. As it was my first time doing it I’m not sure when and how things went off the rails. I may have had the note open in another editor, BBEdit or MarkEdit, at the same time as I was editing in Notenik. I’m not sure about that but I often switch between using MarkEdit for editing content in the body, and editing all the metadata in Notenik.


p.s. I notice that Unique-ID-for-Note isn’t yet recorded in the knowledge base.

One useful thing to remember when it comes to beta testing is that the version of the Knowledge Base contained within the app itself (and accessible via the Help menu) will generally contain a description of the latest changes being tested, but that the version of the Knowledge Base on the website will not be updated until the changes are actually released through the App Store.