Interacting with the "DATA" property of records

Hey DEVONthinkers,

I’ve been tinkering with a different approach to import some items into DEVONthink Pro and was curious if anyone had experience directly writing to the data property of a record.

So far, I haven’t been able to set that property successfully via AppleScript (even with values copied from existing records) and so I’d love to see some working code if anyone has some!

:smiley:

IIRC, the Data property is managed by the file system. What are you trying to do?

@korm – Hi!

For a couple of reasons, I’m playing with the idea of creating a new record with PDF file data loaded in directly via AppleScript. Know there are other ways to do what I want but I thought I’d try, given that the DEVONthink Pro dictionary said this was a “get/set” property and that it supports PDF documents (as well as images, rich texts, and web archives).

I figured the reason it wasn’t working for me was that it didn’t like the format of the data I was using, so I tried to write data from another PDF record to a new record. That didn’t work, so I thought I’d see if anyone else had been able to write to this property successfully.

Interesting problem. I can manually edit “Data” for a record (RTF) in Script Debugger but the viewable content in DEVONthink does not change. I can tell the record to set Data but the property does not change.

@korm – This is similar to my experience.

Anyone out there able to write to the data property of a record?

Here’s an example:


tell application id "DNtp"
	set theRecord to create record with {name:"Test", type:picture} in root of inbox
	set theData to download URL "http://www.devontechnologies.com/fileadmin/templates/main_layout/images/devon_logo.png"
	set data of theRecord to theData
end tell

Not all record types support this property, see script suite (“Currently only supported by PDF documents, images, rich texts and web archives.”)

Hi Christian,

Thanks for jumping in! :smiley:

I’ve been trying to create a new PDF record using the raw data of an existing PDF, without success. Let me extend the code that you posted to demonstrate what I’ve tried (see below)…

tell application id "DNtp"
	set theRecord to create record with {name:"Test", type:picture} in root of inbox
	set theData to download URL "http://www.devontechnologies.com/fileadmin/templates/main_layout/images/devon_logo.png"
	set data of theRecord to theData
	
	-- ☛ LET'S TRY TO COPY VALUE OF DATA PROPERTY TO NEW RECORD…
	
	--THIS SUCCESSFULLY COPIES THE DATA VALUE ABOVE TO A VARIABLE
	set newData to (data of theRecord)
	
	--CREATING A NEW RECORD WITH THIS DATA DOES NOT WORK…
	set newRecord to create record with {name:"Copy Test", type:picture, data:newData} in root of inbox
	
	--THIS APPROACH ALSO DOES NOT WORK…
	set newRecord to create record with {name:"Copy Test 2", type:picture} in root of inbox
	set data of theRecord to newData
	
end tell

The second approach works but there’s a typo, the last line should look like this:


set data of newRecord to newData

10 PRINT "DOUBLE-CHECK SAMPLE CODE BEFORE POSTING TO DEVON FORUM";
20 GOTO 10

Thanks for your help, Christian! :smiley: