Closed (fixed)
Project:
RedHen CRM
Version:
7.x-1.0
Component:
redhen_contact
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
4 Mar 2013 at 14:48 UTC
Updated:
25 Jun 2014 at 00:02 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
philipz commentedWell I don't know if this was needed but here's my patch adding rule to fetch redhen contact entity by email.
It is based on redhen_engagement rules and core rules fetch entity by property rule.
Comment #2
philipz commentedSome corrections.
Comment #3
seanberto commentedI'd like to review this patch. It would be helpful if you could had a moment to shoot us a quick Rules export that leverages this code.
Comment #4
philipz commentedGreat to hear :)
My use case is pretty complicated. I'm using a panels variant to fire a rule that takes a parameter from URL (email) and looks for a contact matching the e-mail. Then it assigns the Entityform registration based on first parameter from URL to the contact if it matches.
I would have to come up with a simpler example for Rules export. I'll try to do that soon.
Comment #5
parampadam commentedIn my use case, i import mails via mailhandler, and connect the imported Mails with my redhen contacts.
If there is no contact i'd like to create one.
The patch in #2 is working, but without an existing Mail address, there is an error message:
Warning: array_shift() expects parameter 1 to be array, boolean given in redhen_contact_rules_action_fetch_by_mail()
My rule is:
{ "rules_mail_import" : {
"LABEL" : "mail import",
"PLUGIN" : "reaction rule",
"REQUIRES" : [ "rules", "redhen_contact", "rules_conditional", "feeds" ],
"ON" : { "feeds_import_mail_importer" : [] },
"IF" : [
{ "node_is_of_type" : { "node" : [ "node" ], "type" : { "value" : { "mails" : "mails" } } } }
],
"DO" : [
{ "fetch_contact_by_mail" : {
"USING" : { "mail" : [ "node:field-mail-from-address" ] },
"PROVIDE" : { "fetched_contact" : { "fetched_contact" : "Fetched contact" } }
}
},
{ "CONDITIONAL" : [
{
"IF" : { "entity_is_of_bundle" : {
"entity" : [ "fetched-contact" ],
"type" : "redhen_contact",
"bundle" : { "value" : { "kontakte" : "kontakte" } }
}
},
"DO" : [
{ "data_set" : { "data" : [ "node:field-contact-ref" ], "value" : [ "fetched-contact" ] } },
{ "entity_save" : { "data" : [ "node" ], "immediate" : 1 } }
]
}
]
}
]
}
}
thanks for help
Comment #6
philipz commentedIt's been a while and I've changed patch #2 since then. Here's new one against latest dev. This one should not cause warnings for you and I've added a condition to check if contact exists by email too.
Comment #7
parampadam commentedYour patch works great, thank you
Comment #8
philipz commentedGreat to hear! I still hope this goes into Redhen Contact so...
Comment #11
gcbThanks @philipz!