Semi-automatic labeling of past due items in a group

A feature of DT is the ability to assign a script to a group or a document (see “Triggered Scripts” in the Help file). This simplistic script, when attached to a group, will look at the first 8 characters of the name of each record in that group, and compare those to a string representing the current date. If the name-string is “less than” today, then it gives the red label to that item. Thus, if one has put due dates in the first 8 characters of the name as yyyymmdd, then the script will flag the past due items.

Simplistic illustration of using triggered scripts to semi-automate flagging past due items, by putting the triggering information into the document name rather than using one of the existing date fields.

Triggered scripts such as this can be used to examine any property of a record - tags, comments, etc., etc.

I’m using this in a group where I store PDF prints of my Groupons to visually flag those that are near death.

(* 	this is a simple script that examines the first 8 characters of the name of each item in a group, and compares those characters to the current date, which has been coerced to string.  If the 8 characters are "less than" today, then the item is flagged with label 1 (red)

	This script could be adapted to assign any other label, or look for any other string.

on triggered(theRecord)
		tell application id "com.devon-technologies.thinkpro2"
			set theSelection to the children of theRecord
			set thisDate to do shell script "date '+%Y%m%d'"
			repeat with thisItem in theSelection
				-- the script resets all labels to "none"
				set the label of thisItem to 0
				set myName to the name of thisItem
				set myDate to the (characters 1 through 8 of myName) as string
				if myDate is less than thisDate then
					-- label 1 is "none"
					set the label of thisItem to 1
				end if
			end repeat
		end tell
	end try
end triggered

Thanks for the script, maybe it’s about time to add “smart rules” (aka smart groups plus actions).

Maybe. Carefully. Actions firing in an un-observed smart group could be powerful … or havoc.