I am trying to fetch a Username where a field equals the value of another field.

On my content type, I have an Entity Reference fields that creates a select list of email addresses.

enter image description here

In Rules, reacting on Creating/Updating nodes in this content type, I am trying to Fetch a User Entity where the value the select list field equals the user's email.

How can I do that?

What I have tried:

I first chose to "Fetch Entity by Property".

The Value is "User", the Property was set to "Name", and the Value was set to the title of the Entity Reference field in the first screenshot (The title of each node in the select list is an email address)

The Fetched Entities are called "fetched_user".

enter image description here

enter image description here

When trying to Add a Variable, it shows multiple values, so I assume I would need to make a loop first.

enter image description here

So I created a loop:

enter image description here

I am very lost on what to do next. Can anyone help me?

Thank you.


2 Answers 2


Your first mistake is in your fetch by property action. The property must be set to email for the users to be found.

After that, the fetch by property action will always return a list even if it's only one result. So you just need fetched-user:0:name. No loop required.

In php, 0 is the first item in a list.


Below is an answer to this part of your question:

on what to do next

It seems that for the list_item being processed, you want to add some extra "test" (similar to a Rules Condition), to verify if the user being processed is the one with the eMail Id you're looking for.

But you're within a Rules Action already, where you cannot add such "test" anymore. Except if you use the Conditional Rules module, which allows you to add such tests within a Rules Action. For some examples of a rule that uses this module, refer to my answer to either of these questions (which include a rule in Rules export format):

Another solution which does not require that extra module, is to add a Rules Component at that very same spot, in which you can add a Rules Condition again, and where you then also add the rest of the required Rules Action(s) to complete the rest of your Rules logic (if that remaining Rules logic can indeed be implemented like so). For more details on that, refer to the answer to "What's the alternative to using the Conditional Rules module?".

Note: I also agree with Niall's additional "recommendations".

  • I have the Conditional Rules module. Can you please give me an example of a "test" with this module? I am not quite sure what you mean.
    – AndrewMRiv
    Commented Dec 9, 2016 at 17:11
  • @AndrewMRiv check my updated answer ... Commented Dec 9, 2016 at 18:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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