Debugging Smart Rule: lowercase

Hi All,

I need a little debugging help please.

Adapting @BLUEFROG lowercase script

tell application id "DNtp"
repeat with thisRecord in (selection as list)
	tell thisRecord
		set {name, comment} to {my lowercase(name), my lowercase(comment)}
	end tell
end repeat
end tell

on lowercase(str)
	do shell script "echo " & (quoted form of (str as string)) & " | tr '[:upper:]' '[:lower:]'"
end lowercase

I’m hitting on an error with the ‘on lowercase’ section.

I’d be grateful for your help :grinning:

Which version of macOS do you use? Here on 10.15.5 your code works as expected.

I’m also on 10.15.5 :thinking:

I just copied your code from the first post and pasted it into a new document in the Script Editor.app.

Okay, now I see the issue, the code is not identical to the screenshot. The on lowercase ... end lowercase block has to be outside the on performSmartRule ... end performSmartRule block.

Thanks for the help! Still learning and trying to get my head around AppleScript :wink: I’ll give it a try. Grateful!

@cgrunenberg I’ve just run a test on my global inbox.

Smart Rule

But I’m getting this Log Error:

Any thoughts as to how best to make this script and smart rule work would be appreciated. Thank you in advance!

Script used:

on performSmartRule(theRecords)
tell application id "DNtp"
	repeat with thisRecord in theRecords
		tell thisRecord in theRecords
			set {name, comment} to {my lowercase(name), my lowercase(comment)}
		end tell
	end repeat
end tell
	
end performSmartRule

on lowercase(str)
	do shell script "echo " & (quoted form of (str as string)) & " | tr '[:upper:]' '[:lower:]'"
end lowercase

This should work:

on performSmartRule(theRecords)
	tell application id "DNtp"
		repeat with thisRecord in theRecords
			tell thisRecord to set {name, comment} to {my lowercase(name), my lowercase(comment)}
		end repeat
	end tell
end performSmartRule

on lowercase(str)
	do shell script "echo " & (quoted form of (str as string)) & " | tr '[:upper:]' '[:lower:]'"
end lowercase

Thank you! That worked! :grinning: :+1: