I wrote a service to move items from the global inbox to a specific group in a specific database.
However, after saving, the service doesn’t show up in the services menu for DTPO.
I have other services in the same folder and they are appearing correctly in the services menu.
The service works if I run it in Automator.
When inspecting the services menu I have a DTPO document selected so it doesn’t appear to be a contextual issue.
Any suggestions as to a possible cause of the problem.
@Allsop is correct --In addition to posting the workflow (a screenshot would do): Where did you save the service; what folder?
If you are frequently moving things to the same destination (i.e., “a specific group in a specific database”), it might be easier to add the group to Favorites in the sidebar and drag your item(s) to that particular Favorite.
Typos - with me always possible but the process works within Automator
Location: A folder I created in documents that holds other services
Good suggestion thank you. Currently what I plan to do is to assign a shortcut key combination to the script and then create a Custom Command in Dragaon Dictate. Thus I should be able to say something like “File Finance” and the note will be moved to the appropriate folder.
@dorich – thanks. I’ve also tried to make this a service and to make it a standalone automator workflow. No joy. Still trying to sort why this is happening
Meanwhile: have you tried doing this with a script? It’s pretty simple:
tell application id "com.devon-technologies.thinkpro2"
set theDatabase to open database "[enter POSIX path of the database in the file system]"
set theSelection to the selection
set theDestination to create location "To" in theDatabase
-- this either makes the group if it did not exist, or uses it as destination if it already exists
repeat with thisItem in theSelection
move record thisItem to theDestination
end repeat
end tell
[size=85]Edit: fixed code error (see below)[/size]
[size=85]Edit 2: made the script so that it can open any database for which you have a POSIX path[/size]
Are these other services, DEVONthink services, or are they services for other apps?
Are you thinking of the services menu at DEVONthink > Services, or the menu that appears in the contextual menu when text is highlighted in a document?
If the former, I don’t believe you’ll be successful. For a service to operate in DEVONthink it has to meet one of the strictures in this list
So, if it is not one of (a) text selected in a document, or (b) a file or folder selected in the file system (selecting a document in DEVONthink is not the same thing), or (c) a part of a web page, then OS X will not display the service and it cannot be activated.
One service is for the System (mount a disk) so not Devon specific but it appears in the menu. The other is for creating a Reminder so also not specific to Devon. The “Mount Disk” service is in the menu for the selection of both a document and text. The new reminder is in the menu when text is highlighted.
DEVONthink > Services
Yes, now you point it out there is no “Services” selection in the Contextual Menu when a DTPO document is selected.
Thanks for the script, I haven’t had time to use it but it should fulfill my needs since it appears that I can activate a script from within Dragon Dictate.
I can’t get your script working. Would you be good enough to take a look for me and see if you can spot my deliberate mistake.
I did some unsuccessful experiments so I returned to your core code to see what happened. Here is what I have at the moment:
tell application id "com.devon-technologies.thinkpro2"
set theDatabase to current database
set theSelection to the selection
set theDestination to create location "To" in theDatabase
-- this either makes the group if it did not exist, or uses it as destination if it already exists
repeat with thisItem in theSelection
move thisItem to theDestination
end repeat
end tell
If I read this correctly it should create a new group called “To” (just for experimental purposes) in the current database and then move the selected item into that group.
It does indeed create a group but its in the Globals section. However, at the end of the script execution it throws an error thus
I can’t find an error with the ID -1701 and when I look at the Dictionary definition of “Move” it seems to indicate that the command needs a target and a destination, both of which appear to be specified.
I believe what I have is an exact replica of your code with the exception that I add “end tell” because the code as it was produced an error.
Another question: How do I specify a different database?
I’ve tried replacing
set theDatabase to current database
with
set theDatabase to "Macintosh HD/Users/username/Documents/Databases/databasename.dtBase2"
But that appears not to work.
I notice in the “Result” line of the editor that the script is still performing on the current database, which indeed it is. The script works but creates the new group in the Global (database?) instead of the target database.
Note, I’m not sure of the current path format so I also tried replacing ‘/’ with ‘:’ but to no avail.
Note: The target database that is the “target” for the document is already open.
I confirmed that I have the current path by trying another simple script to open a database, and it worked.
So the current version of the script, below, has the correct path, but it still creates a new group in the Global (database) not in the targeted database.
This seems to imply that perhaps when you target a different database you have to use some other command?
I’d appreciate any suggestions on how to correct the problem so that the location is either found in the targeted database or created in the targeted database.
tell application id "com.devon-technologies.thinkpro2"
set theDatabase to "~/Documents/DatabasesDTPO/databsename.dtBase2"
set theSelection to the selection
set theDestination to create location "Payments" in theDatabase
-- this either makes the group if it did not exist, or uses it as destination if it already exists
repeat with thisItem in theSelection
move record thisItem to theDestination
end repeat
end tell
Try is the construct for opening something other than the current database and making a group there.
tell application id "com.devon-technologies.thinkpro2"
set theDatabase to open database "~/the path/"
create location "[location name]" in theDatabase
end tell
In case anyone else wants the ability to use a script that moves items from one database to another here is the final solution I have working. My use of this is to take items from the global inbox and transfer them to specific groups in a different database.
All the heavy lifting for this script was done by @korm.
tell application id "com.devon-technologies.thinkpro2"
set theDatabase to open database "~/Documents/DatabasesDTPO/databasename.dtBase2"
set theSelection to the selection
set theDestination to create location "Top Level Group/Child Group" in theDatabase
-- this either makes the group if it did not exist, or uses it as destination if it already exists
repeat with thisItem in theSelection
move record thisItem to theDestination
end repeat
end tell