Problem enabling a plugin

Hi all,

I just created my first plugin and now I’m stuck with the validation / enabling part: It installs but the menu entry stays greyed out. It should always be available, so I tried to let the validate function always return true. Here’s the code:

...
(() => {
	const action = new PlugIn.Action(function(selection, sender){
		var tag = tagNamed("☆")
		if(tag.status === Tag.Status.Active){
			tag.status = Tag.Status.OnHold
		} else {
			tag.status = Tag.Status.Active
		}
	});
 	action.validate = function(selection, sender){
		return (true)
	};	
	return action;
})();

What so I miss?

Thanks in advance,
Johannes

To make code legible, you can enclose it in triple backticks, before and after.

```
code here
```
(() => {
    "use strict";

    const action = new PlugIn.Action(function (selection, sender) {
        var tag = tagNamed("☆")
        if (tag.status === Tag.Status.Active) {
            tag.status = Tag.Status.OnHold
        } else {
            tag.status = Tag.Status.Active
        }
    });
    action.validate = function (selection, sender) {
        return (true)
    };
    return action;
})();
1 Like

Thanks for this tip!

I don’t really know this API – but is “☆” a top-level tag in your database ?

(If it’s nested lower in a tag hierarchy, I think tagNamed may just return null)

1 Like

Thank you, @draft8.

@jobed77, I’ll take a look at this.

@jobed77 you are missing manifest comment delimited by /*{ ... }*. That’s why your plug-in shows as disabled.

Yes, that exactly right.

The structure of a single-file plug-in is expressed in two components:

  • Plug-In Metadata • The plug-in properties that indicate how the plug-in is defined and used.
  • Plug-In Code • The JavaScript-based statements and functions that are read and executed by the host application to perform the indicated procedures.

So, the manifest comment (Plug-In metadata) has this structure:

/*{
	"type": "action",
	"targets": ["omnigraffle", "omnifocus", "omniplan", "omnioutliner"],
	"author": "",
	"identifier": "",
	"version": "1.0",
	"description": "A single-file plug-in.",
	"label": "Plug-In Menu Item Title",
	"shortLabel": "Item Title",
	"paletteLabel": "Toolbar Item",
	"image": "gearshape.fill"
}*/

Thanks for your hints. I skipped the manifest-part here in the forum, it is part of the plugin file.

A good rule of thumb to always submit something that is actually and directly testable.

(Visually checking code is never a good use of a human or their time, and very unlikely to yield much for you. Checking always needs to be done by a machine, so you need to submit something checkable.)

2 Likes