Applescript to merge PDF files

I’m trying to write an Applescript to combine several PDF files in „MyDatabase“
Now DevonThink has a merge command that should handle this request, but it seems I can’t find out how to use it right.
My attempt so far:

tell application id "DNtp"
	set first_record to get record with uuid "237EBA5E-7103-45EB-B765-D221CF28F41F"
	set second_record to get record with uuid "5734953A-E442-4934-9685-C751B3D557E7"
	set mylist to {first_record, second_record}
	set new_record to merge mylist in "MyDatabase"
end tell

If you want to try this, you will have to replace the uuid identifiers with some from your own DB, of course.
The result is as follows:


error "DEVONthink Pro got an error: Some parameter is missing for merge." number -1701

Any parameters other than the list of records are declared optional.
Obviously I am missing something. Any idea?
Has anyone ever managed to merge PDF files in DT via applescript?
Not via CUPS, that is. Any bit of code is appreciated.

The code posted is not using the correct syntax for merge. It should be:


set theResult to merge records {list} in record

A simple approach is

tell application id "DNtp"
	
	set theSelection to the selection
	set theMergedDocuments to merge records theSelection in display group selector
	
end tell

It is not recommended coding practice to hardcode the UUID of a record. Let the script do the heavy lifting of acquiring the record references and passing them on.

Thank you very much, korm! Your help got me a great step forward.
Obviously, I had some difficulties reading the syntax in the .sdef file.

As for the uuids: I plan to compose and call this script from a record within a filemaker database. The PDF files I want to merge are each linked to a FM-record. Therefore, I chose to use the uuid to get a stable link that survives reorganizing and re-indexing my DT database if necessary

The link might not be as stable as you want, especially if the document that’s indexed is changed, removed from the database, and reindexed. But, of course experimentation is the best course of action

Note for anyone wanting to script anything - very little need ever to read (and struggle with) .sdefs. Open the app’s dictionary in the AppleScript Editor included with OS X and look up the term.

That’s what I did. In the window title of the Dictionary appears the name of the .sdef file, so I thought I’d be reading this file. Sorry for the confusion.