0

How can I attachment multiple files from related tables and email them?

Hello,

I've built a system to help us track orders for oversize / overweight permits.  Once we get the permits back, we upload them to their associated state, which is located in the StatePermits table.  What we would like to do is send out one email, that contains all the permits.  Please reference the images for a better understanding.

As you can see here, this Order has 3 permits that all have been approved. 

order_statepermits

The State Permits is a seperate table that contains each idividual permit (pdf file) we get back from each state.  Clicking on AL will take you to that record and you can view the permit under the "Attachments" tab.  Same goes for NY and WA.

Here's what I'd like to happen.  When we click on the "Send All" button, I'd like for Ninox to create an email and attach all of the state permits.  

I've tried adding this code below:

sendEmail({
from: userEmail(),
to: Assignments.Drivers.Email,
subject: "Here are your permits.",
text: "Attached are all your permits for this order. Thank you.",
attachments: files(this)
})

However, it only sends what is attached in the Order's record, not the related State Permits table. 

There will always be at least one state permit, but can end up being many.  This is just one sample scenario.  Another order might have 12 permits, another might have 5.  I need to make sure they all send.

How can I fix this?

Thank you!!

3 replies

null
    • Mconneen
    • 4 yrs ago
    • Reported - view

    Hmm..   this thread talks about appending array 2 with array 1. 

    https://ninoxdb.de/en/forum/technical-help-5ab8fe445fe2b42b7dd39ee7/improved-array-functions-5c1875e559e23c381bb97000

     

    I can see how that works with "text" strings.. but I am not sure how that would work file an array of files. Hmm... 

    • SNJ ENTERPRISES LLC
    • Jeremy_McCloud
    • 4 yrs ago
    • Reported - view

    OK, thanks for the info.  I'll see if I can figure it out.

    • Mconneen
    • 4 yrs ago
    • Reported - view

    My only quick thought would be to pull the attachments all to the top table.. then email .. 

Content aside

  • 4 yrs agoLast active
  • 3Replies
  • 1832Views