Need help triggering a smart rule when clipping via sorter

I’m trying to create a smart rule that will run when I use the sorter to clip a website. I believe I have the smart rule set up correctly to run whenever a new RTF file is added to the inbox of one database. But when I clip a webpage, and the new file shows up in the inbox, the rule does not triggering.

10%20AM

However, if I click on the rule and select “Apply Rule”, it does work as planned.

Any idea what I am missing?

OK, figured something out.

  • When I clip using the Chrome extension Clip to DevonThink (v1.4), it does not trigger the smart rule.
  • But when I clip an article using the sorter in the menu bar (click on the “capture content from” tab, then select Chrome), it does trigger the rule

I just removed the extention and reinstalled it from here, and got the same results

I’m not seeing an issue with the smart rule not being triggered.

However, the Sorter locks open and can’t be closed due to the alert being shown in DEVONthink with this simple smart rule…

The Sorter only closes after responding to the alert. @cgrunenberg would have to comment on that.

@dansroka: Drag the Execute Script to the end and add a Cancel action after the Display Alert. You should see the same behavior as I see, but it should show if the smart rule is triggering correctly.

Alerts are modal and therefore always block the complete interface of the app.

But it shouldn’t lock the Sorter in an open state, should it? This appears to be an error, especially if clipping from a browser in another space. It looks like the Add button is non-functional.

The Sorter isn’t a stand-alone app and therefore also blocked by the alert (and alerts are rarely useful, in smart rules except for debugging)

Noted. Thanks, Criss.

But I was using Notification not Display Alert, which isn’t modal so this shouldn’t be a problem. I removed all notification anyway, and am still running into issues.

It might be my script. I tried setting up my rule with built in actions (mark as read, etc) and they all ran correctly. I switched to one of the built-in scripts (remind me tomorrow), and it ran correctly.

Can you see an issue in this code? (But again, when I manually apply the smart rule, it works correctly.)

on performSmartRule(theRecords)
	tell application id "DNtp"
		repeat with theRecord in theRecords
			tell text of theRecord
				set size to 11
				set size of paragraph 1 to 10
				set size of paragraph 2 to 18
				set color of paragraph 2 to {7196, 17733, 34695}
				set (font of every attribute run whose (font contains "Bold")) to "Georgia Bold"
				set (font of every attribute run whose (font contains "Italic")) to "Georgia Italic"
				set (font of every attribute run whose (font does not contain "Bold" and font does not contain "Italic")) to "Georgia"
				set {alignment, line spacing, paragraph spacing, minimum line height, maximum line height} to {left, 4, 8, 0, 0, 0}
			end tell
		end repeat
	end tell
end performSmartRule

The script looks fine. How large are the documents usually and is the smart rule never executed or only sometimes?

It executes sometimes - but you may be on to something. I’ve been clipping different webpages, and some may be relatively clean (easy for the script) and some may have a lot of extra cruft (hard for the script). Let me check…

The speed of rich text scripting is limited by macOS’ text engine (and of course AppleScript), therefore long documents might require some time. I use a script to reformat added news and remove junk too but I don’t clip complete web pages as rich text, I use the “Take Rich Note” service instead and select the interesting part of the webpage first (or actually DEVONagent Pro does for me :slight_smile: )

I swear this script had run fine on occasion before! But now, I can’t get it to trigger automatically when clipping any webpage of any size. I even tried clipping a very tiny webpage (https://daringfireball.net/linked/2019/06/03/memos) but still it would not trigger.

Interesting — I changed the trigger from “On Clipping” to “On Startup”, and the smart rule is working correctly now, for webpages small and large.

It triggered as expected here using on Clipping

I did use an embedded script here.

Interesting… it didn’t trigger as an external script.

Dropping the file onto the smart rule did execute the script.

Not seeing anything that appears related in the Console.

For me, neither Embedded or External versions of my script work when triggered “on clipping”. Grrr… so weird.

Does it persist after quitting and relaunching DEVONthink?
If so, how about after a machine reboot?

Yes, the problem continues after both relaunching and rebooting.

A screenshot of the Sorter’s clipping tab showing the URL and the settings would be useful - thanks!

Sure. I’m clipping the (very tiny) webpage: https://daringfireball.net/linked/2019/06/05/thompson-wwdc

48%20AM

And just to give you everything, here’s the smart rule:

50%20AM

…and the script that it is running (same as above):

on performSmartRule(theRecords)
	tell application id "DNtp"
		repeat with theRecord in theRecords
			tell text of theRecord
				set size to 11
				set size of paragraph 1 to 10
				set size of paragraph 2 to 18
				set color of paragraph 2 to {7196, 17733, 34695}
				set (font of every attribute run whose (font contains "Bold")) to "Georgia Bold"
				set (font of every attribute run whose (font contains "Italic")) to "Georgia Italic"
				set (font of every attribute run whose (font does not contain "Bold" and font does not contain "Italic")) to "Georgia"
				set {alignment, line spacing, paragraph spacing, minimum line height, maximum line height} to {left, 4, 8, 0, 0, 0}
			end tell
		end repeat
	end tell
end performSmartRule

Thanks for the details! I just tried the same setup but everything’s working as expected, both via the Clip to DEVONthink extension and via the menu extra. However, I used Safari but this shouldn’t make a difference as everything’s performed by the app & the Sorter. And reformatting such a small clipping shouldn’t require much time actually.