0

Rule setup Fetch Entity by Property I'm working with the Twilio module to create a Rule that will send out an SMS message when a user creates a specific piece of content. Here's how I've got things laid out at the moment.

  1. I have a content type called Office (field_office), which contains the regional office name (imported from LDAP, but that probably doesn't matter.)
  2. I have an entity reference user profile field called field_user_office that links to the Office content type.
  3. I created a content type called Blast Message with an entity reference field called field_office_sms which also links to the Office content type. When a user wants to create an SMS they create one of these nodes and select one or more offices to send to.

When I set up my rule I'm not seeing the fields exposed as I expected. I tried adding two Entity has field conditions, Parameter: Entity: [node], Field: field_office_sms and Parameter: Entity: [node], Field: field_mobile_phone, the last of which is the actual mobile number saved in the users' accounts.

How do I navigate from the original content (Blast Message) through the Offices, then to the specific Users who are linked to that office, and ultimately retrieve their mobile phone numbers?

0

You need to use the action: Fetch entity by property.

  1. Condition: Entity has field > node: field_office_sms
  2. Fetch entity by property > User > Property: field_user_office > Value: node: field_office_sms:nid
  3. Loop: List: [entity-fetched]
  4. Action: Send SMS > list-item: field_mobile_phone
  • Interesting -- though I'm running into a problem with the Fetch entity by property action in that I don't have nid as an option. For node:field_office_sms my options are 0, 1, 2, and 3. Also, my Send SMS action doesn't have list-item as a choice as I get (only site, node, and entity-fetched, and entity-fetched has the same 0, 1, 2, and 3 options.) – Sean Cunningham Aug 22 '16 at 13:56
  • You have 0,1,2 and 3 because it's an unlimited field. So you have to go into 0:nid as it's the first (and only?) option. When you do the fetch, you can do the loop and get list items. – Niall Murphy Aug 22 '16 at 15:54
  • Unfortunately trying to force node:field-office-sms:0:nid gives the error "The data type of the configured argument does not match the parameter's value requirement." and it won't save. – Sean Cunningham Aug 24 '16 at 21:37
  • Have you made any progress? Some screenshots could help.. Also try using the action, "convert value" to integer. I've had to do that before. – Niall Murphy Aug 26 '16 at 9:39
  • No luck so far, but screenshots added. I tried adding "convert data type" as I don't see "convert value", but I'm not sure what to do with that once it's in place. – Sean Cunningham Aug 29 '16 at 18:23

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.