docassemble-AssemblyLine icon indicating copy to clipboard operation
docassemble-AssemblyLine copied to clipboard

Order of email attachments when using send_button_html() is opposite of order when using download_list_html()

Open mnewsted opened this issue 1 year ago • 2 comments

When using send_button_html(), is it possible to reverse the order of documents that are attached to the email?

al_user_bundle.download_list_html() puts the docs in the order listed in the object definition, but sometimes (often?) when the files are sent as an email attachment, they are in the reverse order. Maybe this has to do with the properties of the documents in the bundle?

Can these be made consistent, or could there be a way to invert the order when using send_button_html() ? Thanks!

mnewsted avatar Apr 01 '24 20:04 mnewsted

This is still happening. It appears the documents are being added in reverse alphabetical order. Ex: on the download list, I have:

  • instructions
  • motion
  • notice
  • order

but in the email, the attachments are in this order: order, notice, motion, instructions.

mnewsted avatar Feb 08 '25 17:02 mnewsted

It seems to result from this function in Sendgrid's python package, which is described as appending when it is really prepending. Anyway in the next version of jhpyle/docassemble I can adjust for this.

    def _ensure_append(self, new_items, append_to, index=0):
        """Ensure an item is appended to a list or create a new empty list

        :param new_items: the item(s) to append
        :type new_items: list(obj)
        :param append_to: the list on which to append the items
        :type append_to: list()
        :param index: index of the list on which to append the items
        :type index: int
        """
        append_to = append_to or []
        append_to.insert(index, new_items)
        return append_to

jhpyle avatar Jul 25 '25 01:07 jhpyle