Action

Add to Sorted (Bulk)

Posted by kjaymiller, Last update over 6 years ago

Designed for adding multiple tasks in one go, the Bulk Sorted Add loads all items in a list.

If the title starts with “#”, the title will be set as a list.

Steps

  • script

    // See online documentation for examples
    // http://getdrafts.com/scripting
    
    var project = draft.processTemplate('[[Line|1]]');
    console.log(project)
    let baseURL = 'sorted://x-callback-url/add/'
    let reTasks = /(- (\[ \] ){0,1})(.+)/g
    // TODO: Add Logic for - [ ]
    // TODO: Group expression to filter out - ([ ])
    
    tasks = []
    
    while ((match = reTasks.exec(draft.content)) != null) {
     var url = CallbackURL.create();
        url.baseURL = baseURL;
        url.addParameter('title', match[3]);
        if (project.startsWith('#'))
        url.addParameter('list', project.substring(2))
        var success = url.open();
    }

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.