Reports break after Collection is Moved

This afternoon I moved a collection. I used the “File > Move” command to perform the process. When I went to run a report - nothing happened. On investigating I realised that the report script was using a file path to specify the location of a report template. The file path was not updated when the files were moved.

Is it possible to use relative paths or to use system variables in the script files? I’m able to print templateparent and dataparent in the template but when I try to use system variables in the script I get errors. Here’s the output in the log file.

Starting to play script located at /Users/malcolm/Library/Mobile Documents/iCloud~com~powersurgepub~notenik~shared/Documents/WorkRecords/reports/query_script.tcz on 18/01/2024 at 8:08:03 PM
Setting maximum directory depth to 1
Initializing Collection
Collection: /Users/malcolm/Library/Containers/com.powersurgepub.notenik.macos/Data
This path does not point to a Notenik Collection
Problems opening the collection at /Users/malcolm/Library/Containers/com.powersurgepub.notenik.macos/Data
Field label of ticket could not be found in input source
Creating filter rule: ticket eq Artworks
0 Notes passed the filter rules
0 Notes were filtered out
Sort field label of title could not be found in input source
Creating sort field:  ascending
Sort field label of ticket could not be found in input source
Creating sort field:  ascending
Error reading Template from =$templateparent$=/query_template.html -- file:///Users/malcolm/Library/Containers/com.powersurgepub.notenik.macos/Data/
Template Read Error: Error Domain=NSCocoaErrorDomain Code=260 "The file “query_template.html” couldn’t be opened because there is no such file." UserInfo={NSFilePath=/Users/malcolm/Library/Containers/com.powersurgepub.notenik.macos/Data/=$templateparent$=/query_template.html, NSUnderlyingError=0x600000d68300 {Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"}}
Template not ready for output generation!
0 lines read from template file
Script execution complete on 18/01/2024 at 8:08:03 PM

Although Notenik doesn’t do this automatically, you can specify relative paths in the following way (see Knowledge Base).

When the value column contains a path to a folder or a file, then a relative path may be indicated by specifying a prefix of #PATH#. The resulting path will be resolved relative to the location of the script file currently being executed.

As examples:

  • #PATH#../ would resolve to the folder 1 level above the location of the script file.

  • #PATH#templates/page_template.html would resolve to the file named page_template.html located in the templates folder, assuming the templates folder is located in the same parent as the script file itself.

  • #PATH#../templates/page_template.html would resolve to the file named page_template.html located in the templates folder, assuming the script is located in something like a scripts folder that is a peer to the templates folder.

1 Like