Smart Sheets/Records

I’ve been experimenting with adapting the smart groups scripts to Sheets and records. I’d like to be able to set up a “Smart Sheet” that finds matching records and replicates them as records inside itself. Obviously the sheet must have the same fields/columns as the records, but apart from that I don’t see why this should be all that different from smart groups.
No luck so far, the scripts simply don’t work.

Is this even theoretically possible? Or am I just missing something?

Thanks,
Eiron

This should actually be possible but would require several modifications. Maybe you could post the script over here so that I could run & check it.

Now that I know it’s possible, I’ll fiddle some more with scripts and try to get it working - when i have some time to spare. I will post any results here.
Thanks
Eiron

sorry duplicate posting

I’ve tried a basic adaptation of the Smart Folders script but to no avail. Here’s the slightly changed code:


on run
	try
		set scriptPath to POSIX path of (path to me)
		if scriptPath ends with "/" then set scriptPath to ""
		tell application "DEVONthink Pro"
			repeat
				display dialog "Enter the words to use:" default answer "" buttons {"Cancel", "OK"} default button 2
				set theWords to the text returned of the result
				if theWords is not "" then exit repeat
			end repeat
			set theRecord to create record with {name:theWords, type:sheet, columns:{"Notes", "Target", "Order", "Status"}, attached script:scriptPath}
			my triggered(theRecord)
		end tell
	on error error_message number error_number
		if the error_number is not -128 then
			try
				display alert "DEVONthink Pro" message error_message as warning
			on error number error_number
				if error_number is -1708 then display dialog error_message buttons {"OK"} default button 1
			end try
		end if
	end try
end run

on triggered(theRecord)
	try
		tell application "DEVONthink Pro"
			if type of theRecord is sheet then
				set theString to (name of theRecord) as string
				search theString comparison no case within titles operator all words replicate to theRecord with removing replicants
				
			end if
		end tell
	on error error_message number error_number
		if the error_number is not -128 then
			try
				display alert "DEVONthink Pro" message error_message
			on error number error_number
				if error_number is -1708 then display dialog error_message buttons {"OK"} default button 1
			end try
		end if
	end try
end triggered

I’ve only substituted “Sheet” for “group” and defined the columns. What’s needed, I think, is a way to narrow the search results to type “record” and a replication that actually works. For the moment the sheet is created with the right fields but is not populated with records.
I have no idea why.

Unfortunately this does not work - the “search” command can replicate results only to groups. But I’ll change this in the next build so that it’ll be possible to use sheets as the target too.

Thanks Christian, much appreciated. I’ve managed a couple of workarounds but they’re not very efficient.