Error calling create record with {type:rtf} or {type:rtfd}

DTPO’s “DEVONthink.sdef” Applescript definitions help lists for the create record with command:

create record with v : Create a new record.

create record with record : The properties of the record
(‘name’, ‘type’, ‘comment’,‘aliases’, ‘path’, ‘URL’, ‘creation’, ‘modification’, ‘date’, ‘plain text’, ‘rich text’, ‘source’, ‘data’, ‘content’, ‘columns’, ‘cells’ and ‘tags’ are possible values).

[in record] : The destination group for the new record. Uses incoming group or group selector if not specified.

→ record

The allowable types are listed in the definition of a record as:

type (bookmark/feed/group/html/PDF document/picture/plist/quicktime/rtf/rtfd/script/sheet/smart group/txt/unknown/webarchive/xml, r/o) : The type of a record.

==============================
Problem: Attempting to create a record of type “rtf” or “rtfd” causes a fatal AppleScript error.

This code:

tell application id "com.devon-technologies.thinkpro2"
   create record with {name:"Sample", type:rtfd}
end tell

Displays the Group Selector, and allows selection of a Group, but dies with these Replies:

tell application “DEVONthink Pro”
create record with {name:“Sample”, type:rtfd}
–> missing value
end tell
Result:
missing value

And no record is created.

All of the other types (bookmark, feed, group, and so forth) can be created in script, but rtf and rtfd give the “missing value” error.

This looks like a bug, does it not? I am using DTPO 2.3.5.

==============================
Also, I’d very much like to see “create record with” enhanced to support creating new records based on templates located in ~/Library/Application Support/DEVONthink Pro 2/Templates.noindex folder and its subfolders.

This enhancement would also include evaluation and expansion of placeholders (such as %longDate%) in these templates when using the enhanced create record with command.

Thanks.

RTF, RTFD records need rich text


create record with {name:"Sample", rich text:"Bob Loblaw", type:rtfd}

Not an enhancement. Feature exists. Use the “Import” verb in your script and the optional “placeholders” parm — import the template, set the args to do your replacements. For related approaches, examine the script components of the .templatescriptd packages, and so on.

Thank you, korm!

Do you know if this behavior is documented somewhere?

Fantastic! Thank you very much.

There’s no documentation for the scripting dictionary other than the dictionary, AFAIK. And the years of experience in the Scripting Forum, the included scripts and templates, etc.

Maybe It seems to be sensible that text/rich text documents need text content. Though, it is a bit goofy one could script a bookmark record without a URL, OTOH

Maybe. I think it’s a very arguable point, especially since rtf or rtfd content can be added by the user after the script creates the document. In fact, this is desirable behavior in some use cases. I suppose that one can create an empty rtf or rtfd document by passing text to create record with as you demonstrated, then using script to delete the text, leaving an empty document.

RTF and RTFD are unique in that they require content. Any of the other document types can be created without supplying content – I tested them all – and these content-less documents make as little sense as a bookmark without a URL.

Given this, I believe that not documenting this inconsistency is a an important omission.

I did search the forum for details on this topic before I posted, and did not find mention of RTF and RTFD documents requiring content. (That’s not to say that this is not buried somewhere in the forum …) DEVON, please consider writing some additional documentation for scripting, which would point out inconsistencies such as this one. Thanks.

Thanks again korm!

I have discovered that the rich text parameter is required, but an empty string works, too:

create record with {name:"Sample", rich text:"", type:rtfd}
create record with {name:"Sample", rich text:"", type:rtf}

I second the thanks, korm. Didn’t see that one coming but it’s logical.

Cheers!
Jim
BLUEFROG