Can't get smart rule to work

The Display Alert action of this smart rule doesn’t require matching items, therefore the alert is displayed as scheduled.

You could make this action item-specific by inserting e.g. the name placeholder (see contextual menu of text field of this action). Or if this should cause too many alerts you could use a notification instead.

Alerts are rarely useful in smart rules (as smart rules should run faceless and not require user interaction), they’re usually only intended for testing.

A few things:

  1. I dont understand your first sentence about the display alert not requiring matching items. I thought that that was the whole idea of a smart rule.

  2. Clearly the display alert is not useful in the long term. But since I haven’t written a smart rule before I figured that I would build it up the way I write code. Add a little functionality and report on the result. Then add more and report. Etc. When it works I can stop reporting. The first step was “am i matching the right file and triggering the rule correctly”. (And I haven’t been able to get past that one so far :grinning:

Contrary to most event-based triggers like On Import scheduled smart rules do not require matching items. And as the Display Alert text doesn’t contain any item-specific placeholders, it’s displayed every hour in this case.

Adding to @cgrunenberg’s answer: you might want to change the trigger of your rule to “manually” while testing.
If you’re confident that it does what you want, set a trigger on import or some other useful event.

I am not at my computer right now, but I think that the trigger was “hourly” not “on import”. Is that in the same category?

That’s not an event-based trigger, it’s a scheduled one.

Ah. Ok. So if the trigger is schedule-based then the IF part of the rule is ignored and the ACTION is executed. That seems a bit strange but it does explain what I am seeing. I will try changing it.

Thanks.

I stumbled across the same problem and ended up scripting the smart rule actions; so use a smart rule with the same conditions, but the action is for it to run an embedded script, like so:

on performSmartRule(theRecords)
	tell application id "DNtp"
		set thatWorked to 0
		repeat with theRecord in theRecords
			set label of theRecord to 4
			set thatWorked to thatWorked + 1
		end repeat
		if thatWorked is greater than 0 then
			display dialog "New Bill" buttons {"OK"} default button 1
		end if
	end tell
end performSmartRule

Now the dialog will only display if there actually were documents matching the criteria.

PS if you use display notification rather than display dialog then rather than an alert opening up in DT (and stopping you performing any further work until you ok it), the message will be shown in the notification centre (using whatever settings you have chosen for DT)

Thank you. Now I also have a template for when I start apple scripting DT :slight_smile:

you’re very welcome; let me know whether it works for you :mechanical_arm:

1 Like

I agree with @fillmore that (more) users might not expect that behavior. Perhaps @cgrunenberg knows if there’s a specific reason why a scheduled smart rule doesn’t require matching items.

Might I suggest greying out the upper part when hourly/daily/weekly is chosen? Or some other way to give feedback to the user that the matching is disabled with scheduled smart rules.

I couldn’t find this behavior in the manual by the way, but as always I might read over it. (I did find on page 218 though, that scheduled smart rules don’t run on closed databases as of version 3.0.2).

The scheduled smart rules do match conditions, otherwise my script solution wouldn’t work either (theRecords would never be provided).

I guess what is happening is that the conditions are creating a list of records. If that list contains 0 records, the actions (which almost all act on records) will effectively be void. The obvious exception is the alert, which isn’t acting on a record and therefore triggers regardless. In theory that could be something wanted (informing the user that the rule has run). I do feel it would be useful to provide a condition for alerts, though - e.g. alert on run and alert on action (0 documents and > 0 documents respectively). (And whilst I’m at it, the option to alert or to notify).