Hi , I got a script that creates a new Tinderbox note for a selected OmniFocus task. I use the container in which the new notes are created in map view and use a smart adornment that collects all new notes via AgentQuery $Aufgabe_Zugeordnet="Nein" (the script sets this attribute). After running the script I need to manually refresh the Tinderbox’s agents via menu Update Agents Now in order to make the smart adornment collect the new note. This works, but I’d like to automate that step. Already tried to activate menu Update Agents Automatically, but then I still don’t see the new notes immediately on the smart adornment.
There’s the AppleScript command refresh, but it seems I don’t understand how to use it. Tried the script below, it doesn’t update the smart adornment. The script’s result is an empty string and there’s no error message so I’m not sure whether the command is broken or whether I’m not using it correctly.
tell application id "Cere"
tell front document
set theAdornment to adornment "Aufgaben" of note "Tage (Map)" of note "Content"
tell theAdornment
refresh
end tell
end tell
end tell
Also tried this script, same result:
tell application id "Cere"
tell front document
set theAdornment to adornment "Aufgaben" of note "Tage (Map)" of note "Content"
refresh theAdornment
end tell
end tell
-- Create new note in front document
tell application id "Cere"
tell front document
set theTinderboxContainerNote to note "Tage (Map)" of note "Content"
set theNewNote to make new note at theTinderboxContainerNote
tell theNewNote
set name to "ABC"
set value of attribute "Aufgabe_Zugeordnet" to "Nein"
end tell
end tell
end tell
Ack, the misplaced comma in the article now fixed.
Well, I’d not expect update() to do so, given its documentation. But did you mean update(scope)? Slightly confusing as the two do quite different things (or as I understand them).
A challenge here is these are hard to the user to test. Generally, the user’s need for an update is when the user realises a display refresh is needed but the app hasn’t (that disconnect is more subtle than we assume. So to test a ‘refresh’ you need first to generate a situation that ideally should never arise. Not necessarily easy to get on-demand, so one might not be (end-user) testing what one thinks one is testing. I think that’s the original AppleScript confusion above.
In my case it’s easy to test with the demo Tinderbox and demo script. Refresh doesn’t work.
Unfortunately it’s not possible to temporarily deactivate and activate $AgentPriority as AgentPriority has no effect in Smart Adornments.
@satikusala I already tried the update command in a stamp but it only updates the rules and edicts in it’s scope, so it doesn’t help in this case.
@eastgate No matter what I tried the refresh command does not work over here. Could you please take a look or provide a demo script? I guess the command is broken.
Tracking back, I think there might be three issues here.
Correct AppleScript triggering if the refresh command
Scope of effect of the update(scope) action operator (as distinct from the update() operator)
The need to use refresh (#1 above) at all as smart adornments aren’t updating as regularly as the user wants/needs and there is no other way bar the ‘Update all agents now’ menu or a tab+click to force a UI refresh/redraw.
Whilst #1 may indeed have an issue of not working correctly, if #3 allowed more control for Smart Adornments (vs. actual agents), that scenario might not need the expedient of #3 (even if useful in other scenarios). I assume the former don’t honour $AgentPriority less (visual) over-updating of the map occurs. Thus, whilst addressing the latter for Smart Adornments it accidentally ‘broke’ the ability to control the refresh rate of adornment-based agents.
No foul here, as this is a natural side-effect of a big toolbox: many unexpected/unconsidered interactions are possible. Part of this issue is a script (non-UI) change occurring that makes new notes in a fashion that doesn’t inform the map it needs to update as info has changed. Indeed, the use or not of $AgentPriority might be a confusion here.