1

I want to send a push notification to a single Drupal, which, seems simple given the below screen shot.

enter image description here

This works great when the user is always the same (I simply type in the UID). However, in my case, the UID is always different. Is it possible for me to grab the UID from a content field (e.g. from Content Type 'Friends', I have a field named field_target_user) using a token, and have it populate in my Rules' User Identifier field?

6
  • Are you using the Message module? or what are you using for notifications? Also, what is the event that causes the rule to fire?
    – No Sssweat
    Commented Oct 6, 2017 at 0:02
  • @NoSssweat No, I'm simply looking to grab the UID from a field I created in a custom content type.
    – Brittany
    Commented Oct 6, 2017 at 0:16
  • Click on the switch to data selection button and use the corresponding pattern for your field.
    – No Sssweat
    Commented Oct 6, 2017 at 0:59
  • @NoSssweat Oh, if only it were that easy. Lol. User Identifier doesn't seem to want to let me input a token there - simply a uid number.
    – Brittany
    Commented Oct 6, 2017 at 1:33
  • 1
    If my answer still doesn't help, then please include an export of your rue you currently have (as suggested also by @NoSssweat). Also, please add hyperlinks to the modules you're using (wild guess: something like "Push Notifications" maybe?). Commented Oct 6, 2017 at 7:37

1 Answer 1

0

Use the button that says Switch to direct input mode. And verify if you can use any of the tokens shown there as the identifier you're looking for.

If no appropriate token is shown, then try to add an appropriate Rules Condition with Entity has field, to make the field you need available for further processing in the rule. That's also what is mentioned in the Rules UI when you're adding a "data comparison" condition: somewhere it says "The data selector helps you drill down into the data available to Rules. To make entity fields appear in the data selector, you may have to use the condition 'entity has field' (or 'content is of type')". For a video tutorial that illustrates the importance of this Entity has field condition, refer to Data types and data selection, especially what is shown between about 13:30 and 17:30 in that video.

However, as per your "... content field ... from Content Type 'friends'*" (as in your question), the above may not be sufficient yet (= the appropriate token is still not shown). I.e from the label(s) it sounds that this could well be a multi value field (of type entity reference?). In that case you first need to add a "Rules loop" to iterate of the list of friends, so that inside that loop you can use a token related to the uid of the current list item being processed.

The above are just 3 of the typical/possible approaches to get access in a custom rule to some token you're looking for. There are others though, such as:

  • using Rules Action to "Fetch entity by ID", or
  • getting the Views Rules module involved,
  • etc.

Note: In case you're using the Push Notifications module, you may want to have a look at its community documentation related to Rules integration, especially this screenprint on that page seems pretty similar to what you're looking for (if you can reference the node:author token, it should also be possible to reference some other field of a node).

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.