Working Copy round trip : put

Posted by @derekvan, Last update 8 months ago

This script will allow you to send a file to Working Copy that you have previously fetched via this Drafts action:

https://actions.getdrafts.com/a/1S0

Because of the universal url in the first line of your file, you won’t be prompted to manually select the file and location.

Steps

  • script

    // Working Copy commit
    // Commits file grabbed from earlier action. Uses the URL in the title line to determine which file to commit to
    
    const credential = Credential.create("Working Copy Key", "The URL key for Working Copy");
    
    credential.addTextField("key", "URL key");
    
    credential.authorize();
    
    const key = credential.getValue("key");
    
    const baseURL = "working-copy://x-callback-url/write/?";
    
    var cb = CallbackURL.create();
    cb.baseURL = baseURL;
    cb.addParameter("key", key);
    cb.addParameter("url", draft.processTemplate("[[title]]"));
    cb.addParameter("text", draft.processTemplate("[[body]]"));
    cb.addParameter("askcommit", "1");
    
    let success = cb.open();

Options

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