Action

Share Ideas to OmniFocus

Posted by RosemaryOrchard, Last update 8 months ago - Unlisted

Steps

  • script

    const alwaysTags = ['Idea'];
    const otherTags = ['The Sweet Setup', 'Podcast'];
    const multiSelect = false;
    
    if (otherTags.length) {
    	let p = Prompt.create();
    	p.title = 'Choose your tags';
    	p.message = draft.title;
    	p.addSelect('tags', 'Tags', otherTags, [], multiSelect);
    	p.addButton('OK');
    
    	let buttonPressed = p.show();
    
    
    	if (buttonPressed) {
    		let tags = alwaysTags.concat(p.fieldValues['tags']);
    		let task = draft.title + ' @tags(' + tags.join(', ') + ')' + "\n\t" + draft.permalink;
    		addTask(tags);
    	}	
    } else {
    	// There are no optional tags, so don't show a prompt
    	let task = draft.content + ' @tags(' + alwaysTags.join(', ') + ')';
    	addTask(alwaysTags);
    }
    
    function addTask(tags) {
    	const baseURL = "omnifocus:///add";
    
    	let cb = CallbackURL.create();
    	cb.baseURL = baseURL;
    	cb.addParameter("name", draft.title);
    	cb.addParameter("tags", tags.join(', '));
    	cb.addParameter("note", draft.permalink);
    	alert(JSON.stringify(cb));
    	
    	let success = cb.open();
    	if (success) {
    		app.displaySuccessMessage('Added task');
    	} else {
    		context.fail('Failed to add task');
    	}
    }

Options

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