Add to Diary on Dynalist

Posted by sorashima, Last update about 8 hours ago

Set the first line as the title and the rest as a note. Convert drafts tags to Dynalist tags and add them to note. Today’s date is also added to the note as a Dynalist date tag. Then add it to the Dynalist Inbox.

need Dynalist secret token.

When this action is executed for the first time, the token registration screen is displayed. In the second and subsequent executions, the token registered for the first time is read.
To delete the token, tap the “Forget” button of Dynalist in Credentials on Drafts setting screen.

Steps

  • script

    var credential = Credential.create("Secret Token of Dynalist", "Dynalist");
    credential.addPasswordField("token", "Secret Token");
    credential.authorize();
    
    let tagLine = draft.tags.map(t => '#' + t).join(' ');
    let dlDateLine = '!(' + strftime(new Date(), '%F') + ')';
    
    var http = HTTP.create();
    var response = http.request({
      "url": "https://dynalist.io/api/v1/inbox/add",
      "encoding": "json",
      "method": "POST",
      "data": {
        "token": credential.getValue("token"),
        "index": "-1",
        "content": draft.processTemplate('[[title]]'),
        "note": draft.processTemplate('[[body]]') + '\n\n' + tagLine + '\n' + dlDateLine,
        "color": "1"
      }
    });
    
    
    var rText = JSON.parse(response.responseText);
    
    if (response.success) {
    
      if (rText._code == 'Ok') {
       // app.displaySuccessMessage('Posted to Dynalist successfully.');
      } else {
        alert(rText._code + '\n' + rText._msg);
      }
    
    } else {
    
      console.log(response.statusCode);
      console.log(response.error);
      alert(response.statusCode + '\n' + rText._Code + '\n' + rText._msg)
    
    }

Options

  • After Success Archive
    Notification Info
    Log Level Error
Actions available in the Action Directory are uploaded by community members. Use appropriate caution reviewing downloaded actions before use.