It’s one of these weird side-effects when using scripting additions and/or frameworks. This revision works (and uses filename
instead of proposed filename
which might be not be identical to the current filename)
on urlEncode(input)
run script "encodeURIComponent(" & (the quoted form of input) & ");" in "JavaScript"
end urlEncode
on performSmartRule(theRecords)
tell application id "DNtp"
repeat with thisRecord in theRecords
set recordFilename to filename of thisRecord
set URLEncodedFilename to my urlEncode(recordFilename)
set URLEncodedVaultName to my urlEncode("B10")
set newobsidianURL to "obsidian://open?vault=" & URLEncodedVaultName & "&file=" & URLEncodedFilename
add custom meta data newobsidianURL for "obsidianurl" to thisRecord
end repeat
end tell
end performSmartRule