I'm attempting to automate the filing of e-receipts into a digital filing application called Paperless from Mariner Software.

Within the Paperless AppleScript Dictionary, the following is defined for a receipt (class/data type):

receipt n [inh. library item] : A receipt. 
elements contained by .

properties merchant (text) : The merchant's name. amount (text) : amount of the receipt (as a string); can include currency symbol tax (text) : tax or VAT of the receipt (as a string); can include currency symbol payment method (text) : method of payment category (text) : category of receipt notes (text) : notes for the receipt date (date) : date of the receipt custom 1 (text) : custom data 1 custom 2 (text) : custom data 2 custom 3 (text) : custom data 3 file (file) : file reference for the receipt
responds to add.

In my AppleScript, I try to create a new receipt with the following code:

set MerchantID to "Apple -- testing"

tell application "Paperless"
add  receipt with properties {merchant:MerchantID}
end tell

However, it fails with the following error:

error "Paperless got an error: Can’t make receipt into type library item." number -1700 from receipt to library item

What confuses me about the error is that I am attempting to make a receipt which is a class that is inherited from the more general type library item.

Can someone explain how to create a new item based on classes defined like this?

1 Answer 1


receipt is an element belonging to some parent object. As with any instance of an AppleScript element that has already been created, it'll typically be referenced either by index, e.g.

receipt 1 of ...

or by name, e.g.

receipt "MyNamedReceipt" of ...

or by id, e.g.

receipt id "61405882-ee27-4c94-86bb-bcdecc8792ba" of ...

My feeling is that the add command will act on an instance of a library item (including receipt) that already exists. If so, then

add receipt ...

would most likely generate the error you're seeing, because receipt is a class name, where add would be expecting an identifiable element, e.g.

add receipt "MyNamedReceipt" ...

Going by typical nomenclature in the AppleScript world, add commands typically get invoked when one wishes to take a pre-existing object from one location and insert/add it to another. In Paperless, this might be taking a receipt from, say, a folder (or album) of receipts, and adding either a copy of or a reference to (most likely the latter) that receipt to a different folder/album.

The most common way to create new instances of an element in the majority of AppleScriptable applications is by way of the make command (which is part of the standard suite that an application's scripting dictionary is recommended to contain):

makev : Make a new object.
        new type : The class of the new object.
        [at location specifier] : The location at which to insert the object.
        [with data any] : The initial data for the object.
        [with properties record] : The initial values for properties of the object.
    → specifier

If Paperless includes the make command, try using that. It would take a form similar to:

make new receipt with properties {name:"My Receipt", merchant:"Apple", amount:"$249.99", tax:"$0.00"}

You will need to consider which element owns the collection of receipts in which you're attempting to create a new one. If library item is a top-level application object, i.e. owned by application, then the make command should not require the at parameter (if it does, it can be a generic at end of receipts). However, if library item is owned by, say, a library class object, then the make command either needs to occur within tell block targeting that library element (e.g. library 1, or library "MyLibrary"); or it needs the at parameter to describe where to create the new receipt, e.g.

tell application "Paperless"
    make new receipt at library 1 of document 1
end tell

where, for illustrative purposes, I've pre-supposed that library items are contained by libraries are contained by documents are contained by the application.

  • This is a really informative answer, though I haven't gotten the problem fixed yet. As for your suppositions, you are pretty close: library is contained by application; receipts are contained by library. There is a documents class, but it is basically the same as receipts with only minor property differences. There is a generic library item class but per the definition it's just an "abstract class to define a receipt or document." I think one of my issues is how to reference the library currently in use.
    – Allan
    Commented Nov 16, 2019 at 17:05
  • If you wish, you can upload the contents of the scripting definition file to a paste bin, e.g. paste.ee, as an extra pair of eyes can be useful. set the clipboard to (read (path to resource "Paperless.sdef" in bundle app "Paperless") as "utf8") will hopefully copy the file contents to your clipboard for pasting (unless they've been annoying and named their .sdef file something else). I suppose this will do it also: printf "$(</Applications/Paperless.app/Contents/Resources/*.sdef)" | pbcopy. (PS. I don't suppose library 1 does it ?)
    – CJK
    Commented Nov 17, 2019 at 1:52
  • Yeah....library 1 didn't do it. It's a very short dictionary. I've created two links... a PDF on OneDrive and a txt output on Pastebin. Thanks for all your assistance.
    – Allan
    Commented Nov 17, 2019 at 22:55
  • Thanks for uploading those. The library element has a name property, so I'm assuming you can reference any library via that. Examining what gets returned by tell app "Paperless" to return every library and by ``tell app "Paperless" to return the name of every library` will be helpful in getting the correct name, but also in giving you a clue how to get the active library if Paperless allows you to open more than one (if it does, I'm shocked it doesn't allow you to reference by index number, and that might be something to feed back to them).
    – CJK
    Commented Nov 23, 2019 at 2:45
  • Once you have the name of your library, what's the result from tell app "Paperless" to tell the library named "<library name>" to make new receipt with properties {name:"My Receipt", merchant:"Apple", amount:"$249.99"} ?
    – CJK
    Commented Nov 23, 2019 at 2:49

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .