Changing the background color of a line

Hi, I’m trying to make a small plugin to change the background of selections to green. I did:

(() => {
var action = new PlugIn.Action(function(selection) {
// Add code to run when the action is invoked

return action;


However this gives me the error:

TypeError: Style.set is not a function. (In ‘Style.set(Style.Attribute.BackGroundColor,’, ‘Style.set’ is undefined) /Users/albert/Library/Containers/com.omnigroup.OmniOutliner5.MacAppStore/Data/Library/Application Support/Plug-Ins/Green background.omnijs:15:36

Any guidance much appreciated, thank you.

I had posted this originally in How to automate changing the background color of a line and moving to the automation category for more traction.

Please enclose your code between triple backticks (```).

.set is an Instance function, so it should be called on an instance of Style class.

Another problem, .styles is an Instance Property of Selection class. The type of .styles is Array of Style. You should note this property is read-only.


There is a typo there. Should be: Style.Attribute.BackgroundColor

Feel free to ask if anything is unclear.