Action

create everNote

Posted by FlohGro, Last update about 5 years ago

Create a note in evernote via x-callback url

The draft title will be used as note title.
The text should be written in markdown because it will be transferred into an html note to keep the formattings

Steps

  • script

    // evernote x-callback note creation!
    
    const baseURL = "evernote://x-callback-url/new-note";
    
    let nTitle = draft.title;
    let nContent = draft.content;
    let lines = nContent.split('\n');
    
    var newContent = "";
    
    for (line of lines) {
      newContent = newContent + line + '  \n';
    }
    
    draft.content = newContent;
    
    let parsedBody = draft.processTemplate("%%[[body]]%%");
    
    draft.content = nContent;
    draft.update();
    
    //alert(parsedBody);
    
    var cb = CallbackURL.create();
    cb.baseURL = baseURL;
    cb.addParameter("type", "html");
    cb.addParameter("title", nTitle);
    cb.addParameter("text", parsedBody);
    cb.waitForResponse = true;
    //cb.addParameter("",);
    
    
    var success = cb.open();
    
    if (success) {
      console.log("Successfully created a note in evernote!");
      app.displaySuccessMessage("note created :)");
    } else {
      if (cb.status == "cancel") {
        context.cancel("callback response returned cancel!");
        app.displayWarningMessage("callback response returned cancel!");
    
      } else {
        context.fail("callback response returned failure!");
        app.displayErrorMessage("callback response returned failure!");
      }
    }

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.