At first I was puzzled about where/how to install but what worked for me here was to simply double-click the download (after double-clicking the zip). This installed Apply Keyword Styles.omnioutlinerjs in the the bowels of the Library at: Library > Containers > com.omnigroup.OmniOutliner5 > Data > Library > Application Support > PlugIns. Apply Keyword Styles then showed up in my Scripts menu (per the screenshot above).
I understand we need to wait until 5.0.5 build 288342 (or higher) for this to work.
Thanks to @kcase and @tjw for this working example to help get us started. It requires the user to trigger the script by choosing Apply Keyword Styles from the menu, but is a great start.
I’ve had a certain amount of luck using the Timer to automate tasks…
This one will find all rows that have a checked status and set the Date Completed column.
Once it’s instantiated, it will constantly check the document without having to re-run the “Action”
var _ = (function(){
var timer = Timer.repeating(1, function(timer) {
timer.count++;
//console.log(timer.count);
var col = document.outline.columns.byTitle('Date Completed');
var items = document.outline.rootItem.descendants;
for(i in items) {
var item = items[i];
if (item.topic === 'xyzzy') {
timer.cancel();
}
var state = item.state;
var date = item.valueForColumn(col);
if (state === State.Unchecked && date) {
console.log(item.topic + " Date unset");
item.setValueForColumn(null, col);
} else if (state == State.Checked && !date) {
console.log(item.topic + " Date SET");
item.setValueForColumn(new Date(), col);
}
}
});
timer.count = 0;
var action = new PlugIn.Action(function(selection, sender) {
var alert = new Alert("Greg's Automation", "Automation started...");
alert.show(function(){});
});
action.validate = function(selection, sender){
return true;
};
return action;
})();
_;
// COPY & PASTE into editor app. EDIT & SAVE with “.omnijs” file extension.
/*{
"type": "action",
"targets": ["omnioutliner"],
"author": "Greg Smith",
"description": "Sets the Done Date when the item is selected.",
"label": "Greg's Automation",
"paletteLabel": "Greg's Automation"
}*/
@Sal@kcase@draft8 Was Handler ever implemented as described here, such that it would notice when a row changes and automatically update it. Would like to use it for conditional highlighting, e.g. a row contains a certain word in then turn it a certain color.
My goal is to apply colors to rows depending on values contained in the text of a target column, say the Cat column (which may have longer text than shown here, multiple words).
Do you, or any of the others, notice the app slowing down when this is active? I just tested (it works!) but I notice a bit of lag in the text showing up in the screen as I type (probably because the app is checking for the string).
Thanks for the feedback. I unlinked a folder with other scripts/plugins and it improved after that. I had already had this problem in the past, when having a few plugins could cause the app to slowdown.
You might try checking the validation functions in those plug-ins to figure out where the issue is. I have quite a few plug-ins installed without any noticeable slowness, but all it takes is one slow validation function to slow down every interaction: plug-in actions appear in menus (and sometimes other places like toolbars), and menu validation happens with every input event. (I recommend limiting any validation to work that can be done in a small amount of constant time. Or just doing any needed validation when your action is actually getting called, rather than preemptively doing it within the plug-in’s validation function.)