0

I have an Entity form with a file upload and need to include multiple filenames in the mail that is sent to the site admin upon form submission.

If I only allow one file to be uploaded through the form the replacement pattern [entity:field-uploadfield:file] works fine to make rules display the filename in the notification mail. But if I enable the users to upload multiple files the replacement pattern does not work anymore – how can I solve this?

Edit: [entity:field-uppladdarfaltet:0:file] works, but then I'd have to cap the number of files at like 10 and also this doesn't really seem like a "clean" solution. Can I use the :0 :1 :2... format to support an unlimited amount of files?

1

[UPDATED] Your Rule will need to have some additional actions preceding the Send Mail action.

  1. Add variable (Text). Let's call it - [file_list]
  2. Add Loop that loops over your file field [entity:field-uppladdarfaltet] and produces a List Item. Lets call the list item variable [file_n]
  3. Add action Add Variable (text). Call it [file_item]
  4. Add action Set a Data Value. Data to change will be [file_item]. Value to set will be [file-n:file:name]
  5. Add action Set a Data Value. Data to change will be [file_list]. Value to set will be [file-list:value][file-item:value]<br>. This will add each uploaded file's name to the list with a line break after the name.
  6. Print variable [file_list:value] in the email body.

Here's screenshot: enter image description here

| improve this answer | |
  • Alright I'll have a go at it and see if I can get it up and running. – Lenny Mar 10 '16 at 10:58
  • I must be doing something wrong, I can't seem to be able to add a loop for [entity:field-uppladdarfaltet], did you mean like this? http://i.imgur.com/QeLq5Id.png – Lenny Mar 10 '16 at 12:58
  • yes, but remove the double bracket - [[entity:field-uppladdarfaltet]] => [entity:field-uppladdarfaltet] – oksana-c Mar 10 '16 at 13:03
  • Did that, but it still says Error: Data selector entity:field-uppladdarfaltet for parameter list is invalid. I barely have anything to choose from in the list of data selectors, don't know if that is of importance? http://i.imgur.com/nTs8d8X.png – Lenny Mar 10 '16 at 13:09
  • 1
    I updated the answer. Follow those steps now. Had to set another variable in order for the file names to be picked up and fix some value references. I provided an idea for the action at first, that really had to be expanded upon. Such things are not easy to describe precisely step by step without having a test application. – oksana-c Mar 10 '16 at 14:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.