Get DEVONthink group UUID and location for Hazel scripting Macro (v9.2)

I have a lot of Hazel rules that look at a file's name or contents and then move the file to the appropriate group in DEVONthink. Some of the rules called the DT group by UUID and others specified the location-- I always found the location easier to use from a readability standpoint and had started using that exclusively, but just today, after all these years, I learned that UUID method works EVEN IF THE DATABASE IS CLOSED, whereas the "location" method does not. So, to get the best of both worlds, I created the following macro, which creates the Applescript code to be used in an embedded Hazel script. The macro includes the location info (commented out) for readability purposes only, but uses the UUID for the actual file operation.
**The only caveat is you have to select a file in the desired group, not the group name itself.**There may be a way to do the latter, but that exceeds my minimal scripting abilities. There may be other ways to optimize what I did as well. If so, I'm all ears.
I plan to clean this up by making the variables local, or just deleting them at then end, but thought I'd put this up in basic form and people can modify it per their own preferences.

Get UUID and path for Hazel scripting Macro (v9.2)

Get UUID and path for Hazel scripting.kmmacros (2.9 KB)

AS language:

tell application id "DNtp"
	--set img_ib to get record at "%dataPath%" in database "%dataBs%"
	set img_ib to get record with uuid "%dataUUID%"
	import theFile to img_ib
end tell

Correction to above macro--USE THIS INSTEAD--

The first Applescript was changed to:

tell application id "DNtp"
	try
		set theRecords to selection of viewer window 1
		
		set thisRecord to item 1 of theRecords
		
		set theLocation to location of thisRecord
		
		set theDatabase to the name of the database of thisRecord
		
		set curParent to (parent of thisRecord)
		
		set uuParent to item 1 of curParent
		
		set theUUID to get uuid of uuParent
		
		set theParent to theDatabase & " : " & theLocation & " : " & theUUID
		
	end try
end tell

Get UUID and path for Hazel scripting Macro (v9.2)

Get UUID and path for Hazel scripting.kmmacros (3.8 KB)