How to concatenate all token values of a list in a single field within a Rules loop? I am attempting to send a list of uploaded files on a newly created node via email.

In a content type, I have a File Field that allows unlimited values.

Within Rules, I created a loop calling the current item "current_file".



I am trying to concatenate all of the values into one longtext field called "file_list".

I intend to use the token for the value of "file_list" in the body of an email.

Unfortunately, I am unable to do so.

While in Data Selection mode, I can access the tokens created by the loop:



However, while in Direct Input mode, the tokens are not available to me. They are not listed in the "Replacement patterns" section.

When I attempt to fill the value with the following, I have no success:

[node:field-file-list]
[current-file:file:url]


What can be done to make the tokens available to me in Direct Input mode?

If I am doing this incorrectly, is there a different way for me to concatenate all of the URLs of each file so that I can put it in the body of an email action?
If what you're looking for is not available, then just make it available, which is "a different way to concatenate all of the URLs of each file" (as in your question). Read on for more details ...

Have a look at this example of a Rule (in Rules export format), which is a variation of what you're asking for:

{ "rules_show_list_of_fields" : {
    "LABEL" : "Show list of fields",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "rules" ],
    "ON" : { "node_insert" : [], "node_update" : [] },
    "IF" : [
      { "node_is_of_type" : { "node" : [ "node" ], "type" : { "value" : { "article" : "article" } } } }
    ],
    "DO" : [
      { "variable_add" : {
          "USING" : { "type" : "text", "value" : "StartOfList-" },
          "PROVIDE" : { "variable_added" : { "email_list" : "List of eMail IDs" } }
        }
      },
      { "LOOP" : {
          "USING" : { "list" : [ "node:field-email-addresses" ] },
          "ITEM" : { "current_email" : "Current eMail" },
          "DO" : [
            { "data_set" : {
                "data" : [ "email-list" ],
                "value" : "[email-list:value][current-email:value]-"
              }
            }
          ]
        }
      },
      { "data_set" : { "data" : [ "email-list" ], "value" : "[email-list:value]EndOfList" } },
      { "drupal_message" : { "message" : "The value of the email_list variable is: [email-list:value]." } }
    ]
  }
}


Here is a summary of what this rule does:


Add a new variable email_list.
Init the email_list value with some prefix.
For each item within the loop, append the value of that item, followed by a separator character.
Add a suffix to the email_list value. 


In my case I'm using a multi value text field with machine name field_email_addresses, which contains eMail Ids, and just want to dispay a Status message with a concatenation of those eMail IDs, separated by a "-", and with a prefix (=StartOfList) / suffix (=EndOfList). And I also use Rules Events "Update existing node".

Replace the machine name of my list field to your list field, and replace all 'eMail' by 'file' and you should be able to import this rule in your own site (if you have the Rules UI enabled).

Not sure if you want the prefix or suffix, and/or the separator character (="-"). Adapt or remove any of these to fit your needs.

Voilà ...

Demo

Here is how the Status message looks like after you create a new node, or update an existing node (of type Article):


  The value of the email_list variable is: StartOfList-user2@example.com-user4@example.com-EndOfList.