Action

Add Tag

Posted by @mattmaybe, Last update about 4 years ago - Unlisted

Gets current tags on draft
Gets recent drafts tag
Allows new tag
Allows you to assign what tags you want
Adapted from script from @agiletortoise

Steps

  • script (disabled)

    var d = Draft.find("A1D5577C-4D83-4C53-9EA5-7844A7F33A9D");
    eval(d.content);
  • script

    //CHOOSE NEW TAG
    // baseTags are always visible.
    var baseTags = Draft.recentTags();
    baseTags.length = 5;
    
    var currentTags = draft.tags;
    var allTags = baseTags.concat(currentTags);
    var selectableTags = Array.from(new Set(allTags));
    
    // create prompt to display
    var p = Prompt.create();
    p.title = "Assign tags";
    
    p.addSelect("tags", "", selectableTags, currentTags, true);
    
    p.addTextField("othertags", "Other", "", {
      "placeholder": "comma-separated tags",
      "autocapitalization": "none"
    });
    
    p.addButton("Update");
    
    if (p.show()) {
    	var selectedTags = p.fieldValues["tags"];
       for (var tag of currentTags) {
       		draft.removeTag(tag);
       }
    	for (var tag of selectedTags) {
    		draft.addTag(tag);
    	}
    	var otherTags = p.fieldValues["othertags"].split(",");
    	for (var tag of otherTags) {
    	   draft.addTag(tag);
    	}
    	draft.update();
    }
    /*
    
    
    
    
    */

Options

  • After Success Default
    Notification Info
    Log Level Info
Items available in the Drafts Directory are uploaded by community members. Use appropriate caution reviewing downloaded items before use.