Adding attachment

Dan P's Avatar

Dan P

06 Jun, 2020 06:52 PM

This is probably for Sean, but if anyone can help I would appreciate it.

I've written an extension to log in to my bank and download check images. I want to add those images as attachments to the MD register from the extension.
In the API, there is a method setAttachmentTag that requires a string tagName and the file. When I list the tags on existing transactions, I see a tag like this : reg_attach_57f9244e-f2c2-4b32-8ae1-5ed4bd6221fb

My question is what is required in the tagName? I tried it with "" and with "Check" and both seem to work. The attachment is added and viewable just as if I had done it manually. Is this a problem? Is there a way to have MD generate a tag that's more appropriate or does it matter?

Additionally, once I've added the attachment, the transaction is dirty. Do I need to do something about that?
Thanks!

Dan

  1. Support Staff 1 Posted by Sean Reilly on 06 Jun, 2020 10:15 PM

    Sean Reilly's Avatar

    Hi Dan,

    In general the tag should be a unique ID for the attachment. In the moneydance register code I use:

    txn.setAttachmentTag("reg_attach_" + UUID.randomUUID().toString(), attachmentFile);
    txn.getParentTxn().syncItem();
    

    The syncItem() call is necessary to save the link to the file in the transaction, and the attachment file is already encrypted and will be synced to dropbox after the next sync pass.

    Thanks!
    Sean

    --
    Sean Reilly
    Developer, The Infinite Kind
    https://infinitekind.com

  2. 2 Posted by Dan P on 06 Jun, 2020 10:35 PM

    Dan P's Avatar

    Thanks, Sean for replying on a weekend!
    I will make the changes you suggested. (I had seen the syncItem, but was unsure).
    You are the best.

  3. Dan P closed this discussion on 30 Aug, 2020 02:29 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac