URL link to a drafts 5 draft

This maybe a stupid question but is there a way to get a url link to a current draft I’m working on so I can reference in my to do app?

1 Like

If you tap the ⓘ button in the toolbar, there’s a “Copy Link to Draft” link near the top.

4 Likes

and you can also do it in a script action step:

http://actions.getdrafts.com/a/1I7

(() => {
    'use strict';

    const strURL = draft.permalink;
    
    return (
        app.setClipboard(strURL),
        alert('Copied to clipboard:\n\n' + strURL),
        strURL
    );
})();

Copy draft link to clipboard action

Thanks could see for looking…

The draft object has a permalink property. If you are going to script a link, it would be more reliable to use that property than build the URL from a string.

4 Likes

Thanks ! Updated above and at http://actions.getdrafts.com/a/1I7

2 Likes

I’m new to this so I am piecing the puzzle together… I’m looking for something similar. I have an action that sends any open task to todist. Within the step I’d love to include the draft url for reference.

It’s going to involve the permalink in exactly the same way. But without seeing your exact action and perhaps sample data it’s a bit hard to explain or advise further with any confidence it’ll make sense for what you have.

I’m building on https://actions.getdrafts.com/a/1OQ.

On line 15 I inserted draft.permalink
eg. task = draft.permalink + “(” + task.trim() + “)”;
The action runs fine, but when I click to open the link from my iPad or iphone it shows the “Draft not found”. But the url is exactly as if I copied directly from the drafts app and pasted it into Todosit.

Try it with this line instead:

task = draft.permalink + " (" + task.trim() + ")";

Note the space within the first set of double quotes, before the open bracket.

Without that, I think that the actual URL, the bracket, and the content of the task up to the first space will be the URL it tries to open and then can’t find.

2 Likes

That solved it! The last portion for me is to insert the Draft title. Not sure how to do that. Something like this… maybe …
task = draft.permalink + " (" + task.trim() + [[Safe_title]]")";

draft.title should suffice.

task = draft.permalink + " (" + task.trim() + " : " + draft.title + ")";

Safe title is more for use with file names as it strips out any characters that may be used for file path separators, wild cards, etc.

  • [[safe_title]] File name safe version of the first line with ASCII control characters and path separators that can interfere with file names removed (/:*?<>|#).

Also to use the safe title template tag you would need to use the processTemplate() draft method (see Draft instance functions).

2 Likes

Excellent question that has made for some food productivity hacks for me. So thanks.

1 Like

Could you post the action? This would be perfect.

I never actually modified the action as I don’t use it. I just explained where I would modify the code. But, it should be this.

Please note I have not tested this modification, only suggested the modification in response to a question.

Thanks for getting back to me. I tried installing the action and running but I get an error.

Script Error: ReferenceError: Can’t find variable: ctErrors
Line number: 21, Column 12

I don’t know much about code, so I don’t know much about what that’s says :confused:

It is saying on line 21 there is a variable called ctErrors it knows nothing about. There’s no creation of it anywhere earlier in the code, so that makes sense.

I’ve updated the link above with that line commented out (two forward slashes in front of it). Feel free to update and try again or modify it yourself.