0

Rules (not) triggered with Bulk Media Upload

I have a node type called 'uploads' that includes a user reference field to make each upload particular/available to a certain user.

I have added a rule so when a new upload is added, they are e-mailed to let them know there's something new for them to see once they're logged in.

This works fine when adding uploads (nodes) one at a time, but I'm also using "Bulk Media Upload" (https://www.drupal.org/project/bulk_media_upload) to allow for multiple uploads/node creation, at which point the rules fail with the following error:

"Unable to get the data value for the variable or parameter id. Error: Unable to get the data property uid as the parent data structure is not set."

I realize that Bulk Media Upload is on/past the outs; but I do need the functionality it provides and am unsure as to why the data isn't available doing things this way when they are doing things one at a time. The references are made the same way in either case since Bulk Media Upload uses/requires the same values.

Edit - Ok, here's the rule being used:

            { "rules_results_uploaded" : {
                "LABEL" : "Results Uploaded",
                "PLUGIN" : "reaction rule",
                "OWNER" : "rules",
                "REQUIRES" : [ "rules", "php" ],
                "ON" : { "node_insert--uploads" : { "bundle" : "uploads" } },
                "DO" : [
                  { "entity_fetch" : {
                      "USING" : { "type" : "user", "id" : [ "node:field-for-user:uid" ] },
                      "PROVIDE" : { "entity_fetched" : { "entity_fetched" : "Fetched entity" } }
                    }
                  },
                  { "drupal_message" : { "message" : "Receipt of the sample on \u003C?php echo $data[\u0027components\u0027][\u0027sample_received\u0027][\u0027value\u0027][0]; ?\u003E has been acknowledged.  \r\n\r\nAn e-mail will be sent to [entity-fetched:field-practitioner-name] at [entity-fetched:mail]" } },
                  { "mail" : {
                      "to" : "[entity-fetched:mail]",
                      "subject" : "Your Sample Results Have Been Uploaded",
                      "message" : "Dear [entity-fetched:field-practitioner-name],\r\n\r\nNew sample results are now available on your account.",
                      "from" : "results@afakewebsite.com",
                      "language" : [ "" ]
                    }
                  }
                ]
              }
            }

Again, the rule works fine when fine when adding a new node of the type 'uploads' one at a time, it just doesn't work using bulk media upload (though triggering multiple times.) Perhaps I'm misunderstanding how BMU works.

Any thoughts or alternatives still much appreciated.

  • please edit your question to include an export of your rule – Pierre.Vriens Dec 16 '17 at 7:09
0

As noted, your rule is setup for serial upload operations; BMU sets the entities in a batch process, rather than one reference/file at a time.

You may be able to overcome the race condition resulting from the rule firing and batch processing by triggering the rule on node save rather than individual file uploads while editing the node. This will ensure each file has a Drupal FID assigned and has been fully added to the files table in Drupal for referencing.

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.