I’ve been running a useful callback URL from Drafts for some time now, which sends notes/annotations (along with their tags) to a specific folder:
I wonder if it is possible to further develop this scheme to file these into a new folder within that folder (or if not, simply into the inbox?). I know that there is a URL scheme for new groups, but I’m not quite sure how to draw it into this script (if it is indeed possible). A small thing that would make reduce friction. (In an ideal world, I’d also have the ability to enter the folder name, but I think I’m into shortcuts territory there).
I wonder if it is possible to further develop this scheme to file these into a new folder within that folder (or if not, simply into the inbox?).
Into a new folder, i.e., created by the URL = no.
The Inbox or any group in a DEVONthink database can be targeted by its UUID.
One note: A URL scheme does not have to be an x-calback-url. That is a specific type of URL scheme meant to return data to the calling application.
I don’t use Drafts but if you could use a callback to initiate a second URL scheme, perhaps as a custom
success= parameter, it may be possible to create a group, then pass the UUID to a second URL scheme.
Ahh, ok, makes sense. Maybe I’ll poke around the Drafts forum. As I tend to have many notes that I’m sending over to DTTG, batch operations are necessary. Apparently batch operations can be problematic on URL based steps, and can fail, which is why
Greg Pierce over at Drafts encourages the use of callback URL.
Greg Pierce over at Drafts encourages the use of callback URL
Well, considering he invented it…
It’s not harmful to use, but not all URL schemes are callbacks and neither are callbacks always necessary. In fact, I suggest you don’t use them unless you need to. Automation in iOS is quite inelegant and unpleasant with all the app swapping going on. An unneeded callback adds yet another app swap without purpose.
On the very top of the search results for “batch” in the Drafts user forum is a thread created by a certain aroddick. So I assume that I, who has just tinkered around a bit with the provided Send to DEVONthink action to get his notes into DTTG a little more comfortably, can be of little help for you.
I still want to throw in what I have to offer.
First, of course you can script a prompt in Drafts where you can enter the name of the new group. And that name can be handed over to the URL scheme to create the group.
A faster but maybe less elegant way: You use the first or the last line of the note for the name of the new group and let the script hand that over to the URL scheme.
The next step is more difficult. If you not only create a new group in a fixed location set in the URL scheme but want to pick that location too. Because then you will have to know the UUID of that location.
There is a number of possible ways how to handle this that come to my mind:
You could script another prompt to type in the UUID of the location you want to create the new group in. Not impossible but highly impractical.
You could script an array that links all UUIDs to the names of the locations and prompts a drop down list with the names. You pick the name, the script sends the respective UUID to the URL scheme. Comfortable when actually sending a note, a lot of effort for maintenance as every newly created location must be added to the array manually. And deleted ones deleted, etc. Impractical again? That depends on how fluid your scheme of locations is.
If you only use a manageable number of locations in DTTG you could make copies of the action for each location and hardwire the respective UUID into the URL schemes. Then you would not have a single “Send to DEVONthink” action but a “Send to DEVONthink Inbox”, “Send to DEVONthink Monthly Report Group”, etc. action. (That’s how I use my Drafts to DTTG actions, just without the creation of a new group and without batch apply.)
Then follows the part where the callback action sends the UUID of the newly created group back to Drafts which then automatically starts another URL scheme with the UUID as the location for the note. To my understanding this should be possible but I have no experience in this whatsoever.
All of this might work considered you don’t want to send more than one note to each newly created group. Because the newly created groups are not available as target locations yet (see above: maintenance!) and trying to create them again when they already exist would probably cause trouble.
Assuming that DT 3 is your main program and DTTG is just its handy companion app there might be a whole different solution: Tags. Use tags in the notes that start with a specified sequence of characters— say “- - -”—as group identifiers and let a scripted smart rules in DT 3 do the rest. The script would have to look up if a group named like the tag (minus the start sequence) exists. If so it sorts the note into that group. If not it creates the group. Afterwards it removes the tag.
My post got quite lenghty. What I only wanted to say is: I can’t wait to get my hands on your perfect Send to DTTG script.
Thanks suavito! Some decent options here. I am on DT3, but am (perhaps foolishly) thinking I’d prefer this all to happen in the mobile environment. But you are right regarding the power of tags and smart rules. I’m going to have to think on this (and explore the possibilities of linking the folder action to the create text scheme).