I am attempting to use the rules, webform and webform rules modules to send an email to the email addresses of fetched submissions after existing content is edited.
QUESTION: Can anyone see why my rules are not sending emails?
The rules I have configured are:
event -After updating existing content
Actions -Fetch webform submissions of node ID
Loop -fetched submissions
loop action -Send mail.
For the send mail TO field I have set the PHP evaluation field to:
<?php print $list_itemb->data['components']['email_address']['value'][0]; ?>
I have also tried:
<?php print $list_itemb->data['email_address']['value'][0]; ?>
I have attempted to follow the steps outlined in the below submission but it is still not working correctly.
Link: https://drupal.stackexchange.com/questions/69134/send-mail-to-email-addresses-from-webform-when-a-content-is-saved
EXPORT OF RULES:
{ "rules_test_form_final" : {
"LABEL" : "Test form final",
"PLUGIN" : "reaction rule",
"OWNER" : "rules",
"REQUIRES" : [ "webform_rules", "php", "rules" ],
"ON" : { "node_update" : [] },
"DO" : [
{ "webform_submissions_load" : {
"USING" : { "nid" : "3333" },
"PROVIDE" : { "submissions" : { "submissions" : "Fetched submissions" } }
}
},
{ "LOOP" : {
"USING" : { "list" : [ "submissions" ] },
"ITEM" : { "list_itemb" : "Current list item" },
"DO" : [
{ "mail" : {
"to" : "\u003C?php print $list_itemb-\u003Edata[\u0027components\u0027][\u0027title\u0027][\u0027value\u0027][0]; ?\u003E",
"subject" : "final test",
"message" : "test",
"language" : [ "" ]
}
}
]
}
}
]
}
}
Calling submission data using the fetch submissions action in the Drupal Rules module changes the format of the array.
The correct call is below:
<?php print $list_itemb->data['61'][0]; ?>
Related
I am trying to write a firebase rule that checks to see if you have access to a child of one node by checking the data of another node. The issue I am having is accessing the other node's data because it is stored under an AutoId. How would I access the data under the AutoId?
Here is my database structure:
{
"products" : {
"Product001" : {
"ownerId" : "User002",
"productName": "Name"
},
"product002" : {
"ownerId" : "User001",
"productName": "Name"
}
},
"shares" : {
"share001" : {
"accepted" : true,
"ownerId" : "User002",
"productId" : "Product001",
"userEmail" : "example#email.com"
},
"share002" : {
"accepted" : true,
"ownerId" : "User001",
"productId" : "Product002",
"userEmail" : "email#exaple.com"
}
},
"users" : {
"User001" : {
"email" : "example#email.com",
"firstName" : "John",
"lastName" : "Smith"
},
"User002" : {
"email" : "email#example.com",
"firstName" : "John",
"lastName" : "Smith"
}
}
}
Here is the section of the rules that is causing me a problem:
"products":{
"$productId":{
".read":"root.child('shares').child($shareId).child('productId').val() === $productId && root.child('shares').child($shareId).child('ownerId').val() === auth.uid",
".write":"root.child('shares').child($shareId).child('productId').val() === $productId && root.child('shares').child($shareId).child('ownerId').val() === auth.uid"
}
}
Essentially, a user is only allowed to access a premises if they are in a share that contains their information.
Thank you for any advice.
There is no way in security rules to query or search another node, as the performance of that would be way too unreliable. So in your current data model it is not possible to allow the user access to a product if they have any shares for that product.
You'll need to have a list somewhere in a knowable path of the products the user can read. For example, say that you keep a list of the products the user is interested in:
"interests" : {
"User001" : {
"Product001": true,
"Product002": true
},
Now you can allow the user access to all products they follow with:
"products":{
"$productId":{
".read":"root.child('interests').child(auth.uid).child($productId).exists()",
".write": ...
}
}
New Dgraph user wondering if anyone can provide me with an example recursive count and sum query to help get me going.
The data looks like this (there are more predicates, but left out for simplicity):
{
"uid" : <0x1>,
"url" : "example.com",
"link" : [
{
"uid" : <0x2>,
"url" : "example2.com",
"link" : [
{
"uid" : <0x4>,
"url" : "example4.com",
"link" : [
{
"uid" : <0x6>,
"url" : "example6.com",
"link" : [
{
etc...
}
]
}
]
},
{
"uid" : <0x5>,
"url" : "example5.com",
}
]
},
{
"uid" : <0x2>,
"url" : "example2.com",
"link" : [
{
etc ....
}
},
]
}
Just a home page with n-links which each have n-links and the depth, obviously, can vary. Just hoping for a good example of how to count all the links for each url and sum them up. I will add different filters to the query at some point, but just wanting to see a basic query to help get me going. Thanks.
I have 3 rules which make up my "membership".
Assign role when product X gets purchased (This one works!)
Send a reminder email after 2 minutes.
Remove role after 4 minutes.
Please note the 2 and 4 minutes are only there for testing purposes, they will become 350 and 365 days.
While both 2. or 3. work, I have two issues:
Rules n2 and n3 fire at the same time, so at 2 mins mark not only the email is sent, but also the role is removed.
Let's say user MARK purchase product X, and a minute after, JOE does the same. After 2 minutes that MARK purchased the product X, MARK gets the reminder email, his role is removed but also JOE gets the reminder email, and his role is removed.
It seems as soon something triggers, all do.
As you can see from the exports, I made one rule trigger from x minutes of the commerce order completed, and the other from the role assigned, thinking that relating to 2 different events, I would solve the issue. It didn't work.
Here are the exports of my rules:
Rule "Send a reminder" component:
{ "rules_sends_email_to_pipps_reminder_1_week_prior_expiry" : {
"LABEL" : "Sends Email to PIPPS Reminder 1 week prior expiry",
"PLUGIN" : "rule set",
"OWNER" : "rules",
"REQUIRES" : [ "rules" ],
"USES VARIABLES" : { "user_argument" : { "label" : "User {argument}", "type" : "user" } },
"RULES" : [
{ "RULE" : {
"DO" : [
{ "mail" : {
"to" : "[commerce-order:mail]",
"subject" : "Heads up!",
"message" : "Yo! Heads up!",
"from" : "pipps#siteemail.com",
"language" : [ "site:current-cart-order:state" ]
}
}
],
"LABEL" : "Send email reminder to PIPPS"
}
}
]
}
}
Rule "Send a reminder" trigger:
{ "rules_send_reminder_email_to_pipps_role_trigger_rule_" : {
"LABEL" : "Send reminder email to PIPPS Role {trigger rule}",
"PLUGIN" : "reaction rule",
"OWNER" : "rules",
"REQUIRES" : [ "commerce_order", "rules", "rules_scheduler", "commerce_checkout" ],
"ON" : { "commerce_checkout_complete" : [] },
"IF" : [
{ "commerce_order_contains_product" : {
"commerce_order" : [ "commerce_order" ],
"product_id" : "PIPPS",
"operator" : "=",
"value" : "1"
}
}
],
"DO" : [
{ "schedule" : {
"component" : "rules_sends_email_to_pipps_reminder_1_week_prior_expiry",
"date" : {
"select" : "site:current-cart-order:created",
"date_offset" : { "value" : 120 }
},
"identifier" : "Reminder email to [account:uid]",
"param_user_argument" : [ "commerce-order:owner" ]
}
}
]
}
}
Rule "Role Expire" component:
{ "rules_expire_pipps_role_rule_set_" : {
"LABEL" : "Expire PIPPS Role {rule_set}",
"PLUGIN" : "rule set",
"OWNER" : "rules",
"REQUIRES" : [ "rules" ],
"USES VARIABLES" : { "user_argument" : { "label" : "User {argument}", "type" : "user" } },
"RULES" : [
{ "RULE" : {
"DO" : [
{ "user_remove_role" : {
"account" : [ "user_argument" ],
"roles" : { "value" : { "13" : "13" } }
}
}
],
"LABEL" : "Expire action {rule}"
}
}
]
}
}
Rule "Expire Role" trigger:
{ "rules_remove_pipps_role_trigger_rule_" : {
"LABEL" : "Remove PIPPS Role {trigger rule}",
"PLUGIN" : "reaction rule",
"OWNER" : "rules",
"REQUIRES" : [ "rules", "rules_scheduler" ],
"ON" : { "user_update" : [] },
"IF" : [
{ "user_has_role" : { "account" : [ "account" ], "roles" : { "value" : { "13" : "13" } } } }
],
"DO" : [
{ "schedule" : {
"component" : "rules_expire_pipps_role_rule_set_",
"date" : {
"select" : "site:current-cart-order:created",
"date_offset" : { "value" : 240 }
},
"identifier" : "Remove User role [account:uid]",
"param_user_argument" : [ "account" ]
}
}
]
}
}
Any suggestion is very appreciated! Thanks.
Your Rules (and Rules Components), seem to "work as implemented" ... You 'issue' appears to be that you should be more patient during your testing ... Read on for more details ...
Understanding what is happening
After a rule is scheduled (using the Rules Scheduler submodule), it will only actually execute next time cron runs.
Example:
schedule a 1st Rules Component to execute at timestamp X1.
if the next time that cron runs is at Y mins after timestamp X1, then the execution of this 1st Rules Component will only happen then (= at Y mins after timestamp X1).
schedule a 2nd Rules Component to execute at timestamp X2.
if the next time that cron runs is at Y mins after timestamp X2, then the execution of this 2nd Rules Component will only happen then (= at Y mins after timestamp X2).
Because of what is described in the scenario of your question, it seems that timestamp X2 is happening BEFORE Y mins after timestamp X1. That would also explain why BOTH Rules Components actually execute (more or less) at the same time.
Remedy to make it work as you really want
Assuming that your cron jobs are running every hour, a straight forward (minor) fix to your Rules Components that is scheduled after 4 minutes, would be to schedule them after (e.g) 2 hours instead. So that you are sure that both Rules Component are not actually executed during the very same cron job.
When I query /mycollections?ql=Select * where name='dfsdfsdfsdfsdfsdf' I get
{
"action" : "get",
"application" : "859e6180-de8a-11e4-9360-f1aabbc15f58",
"params" : {
"ql" : [ "Select * where name='dfsdfsdfsdfsdfsdf'" ]
},
"path" : "/mycollections",
"uri" : "http://localhost:8080/myorg/myapp/mycollections",
"entities" : [ {
"uuid" : "2ff8961a-dea8-11e4-996b-63ce373ace35",
"type" : "mycollection",
"name" : "dfsdfsdfsdfsdfsdf",
"created" : 1428577466865,
"modified" : 1428577466865,
"metadata" : {
"path" : "/mycollections/2ff8961a-dea8-11e4-996b-63ce373ace35",
"connections" : {
"relations" : "/mycollections/2ff8961a-dea8-11e4-996b-63ce373ace35/relations"
}
}
} ],
"timestamp" : 1428589309204,
"duration" : 53,
"organization" : "myorg",
"applicationName" : "myapp",
"count" : 1
}
Now if I query /mycollections/2ff8961a-dea8-11e4-996b-63ce373ace35/relations I get the second entity
{
"action" : "get",
"application" : "859e6180-de8a-11e4-9360-f1aabbc15f58",
"params" : { },
"path" : "/mycollections/2ff8961a-dea8-11e4-996b-63ce373ace35/relations",
"uri" : "http://localhost:8080/myorg/myapp/mycollections/2ff8961a-dea8-11e4-996b-63ce373ace35/relations",
"entities" : [ {
"uuid" : "56a1185a-dec1-11e4-9ac0-e9343f86b604",
"type" : "secondcollection",
"name" : "coucou",
"created" : 1428588269141,
"modified" : 1428588269141,
"metadata" : {
"connecting" : {
"relations" : "/mycollections/2ff8961a-dea8-11e4-996b-63ce373ace35/relations/56a1185a-dec1-11e4-9ac0-e9343f86b604/connecting/relations"
},
"path" : "/mycollections/2ff8961a-dea8-11e4-996b-63ce373ace35/relations/56a1185a-dec1-11e4-9ac0-e9343f86b604"
}
} ],
"timestamp" : 1428589668542,
"duration" : 51,
"organization" : "myorg",
"applicationName" : "myapp"
}
What I want is that instead of providing me the path of the related entity Usergrid directly nest it in the first JSON answer so that I only need to make a single http request instead of two.
You cannot. Usergrid is not designed in that way. You need to write an extra wrapper rest endpoint to simulate one response.
Not sure what DB you are using. If you are using document db like mongo then you can write a node.js scripts to do this manipulation. Apigee has volvo.js check is it possible to do scripting.
I am using accounts-google package to register users
I have multiple users stored in mongo
db.users.find()
{ "_id" : "av8Dxwkf5BC59fzQN", "profile" : { "avatar" : "https://lh3.googleusercontent.com/-rREuhQEDLDY/AAAAAAAAAAI/AAAAAAAADNs/x764bovDfQo/photo.jpg", "email" : "lfender6445#gmail.com", "name" : "Luke Fender", "room" : "2" }, "services" : { "resume" : { "loginTokens" : [ { "when" : ISODate("2014-04-26T19:34:52.195Z"), "hashedToken" : "8na48dlKQdTnmPEvvxBrWOm3FQcWFnDE0VnGfL4hlhM=" } ] } } }
{ "_id" : "6YJKb7umMs2ycHCPx", "profile" : { "avatar" : "https://lh3.googleusercontent.com/-rREuhQEDLDY/AAAAAAAAAAI/AAAAAAAADNs/x764bovDfQo/photo.jpg", "email" : "lfender6445#gmail.com", "name" : "Luke Fender", "room" : "2" }, "services" : { "resume" : { "loginTokens" : [ { "when" : ISODate("2014-04-26T19:35:00.185Z"), "hashedToken" : "d/vnEQMRlc4VI8pXcYmBvB+MqQLAFfAKsKksjCXapfM=" } ] } } }
But Meteor.users.find().fetch() returns document for logged in user only - shouldn't this return entire collection? Are the other users somehow private by default?
This is the default behaviour. You can only see who you're logged in as.
You can make a custom publish function to publish a custom subset/what you want. In the example below I publish all the users (only the profile field)
Server side code
Meteor.publish('users', function() {
return Meteor.users.find({}, {fields:{profile: true}});
});
Client side code
Meteor.subscribe("users");
You might want to alter these to only publish what is relevant to the user. If you have over 100 users this begins to get wasteful to publish all of them to the client.