Script fails when run in batch job - on performSmartRule (Can’t get location group of content id 64221 of database id 11.)

It might be late, but I can’t see, why this script fails when run as batch job - DT 4.1.1.

When I run it as normal script within Script Debugger or Script Editor, it works fine.

image

on performSmartRule(theRecords)
	tell application id "DNtp"
		repeat with theRecord in theRecords
			local theParent
			set theParent to (location group of theRecord)
			
			local tagsRecord
			set tagsRecord to tags of theRecord
			
			local tagsParent
			set tagsParent to tags of theParent
			
			set tags of theRecord to tagsRecord & tagsParent
			set rating of theRecord to (rating of theParent)
		end repeat
		
	end tell
end performSmartRule

script version

tell application id "DNtp" to my performSmartRule(selected records)

on performSmartRule(theRecords)
	tell application id "DNtp"
		repeat with theRecord in theRecords
			local theParent
			set theParent to (location group of theRecord)
			
			local tagsRecord
			set tagsRecord to tags of theRecord
			
			local tagsParent
			set tagsParent to tags of theParent
			
			set tags of theRecord to tagsRecord & tagsParent
			set rating of theRecord to (rating of theParent)
		end repeat
		
	end tell
end performSmartRule

I’m not seeing any issue with your code and a group structure similar to yours…

I am curious why you’re using local variables ?

And this code is simpler and works properly…

on performsmartrule(therecords)
	tell application id "DNtp"
		repeat with theRecord in therecords
			set theParent to (location group of theRecord)
			set tags of theRecord to (tags of theRecord) & (tags of theParent)
			set rating of theRecord to (rating of theParent)
		end repeat
	end tell
end performsmartrule

I’m a Script Debugger user. Using local makes variables visible within the Debugger.

Unfortunately, your script failed as well.

Rebooting macOS fixed the problem. :man_shrugging: I thought, that is just true for windows. Two hours for nothing. Thanks a lot for helping me out at identifying the real issue! Having a known working example as always good while troubleshooting.

Maybe something was cached by the AppleScript runner stuff, while I try to get a smart rule running using https://discourse.devontechnologies.com/t/smart-rule-fails-only-when-triggered-as-a-smart-rule-can-t-get-name-of-class-dtcn-id-1296597-of-class-dtkb-id-2/70691/28.

You’re welcome.

Definitely not a Windows thing. We recommend rebooting your devices at least once a week, both Mac and mobile. There is no prize for having the longest uptime and rebooting can absolutely help keep things running more smoothly.

2 Likes