3
votes

hey everyone, hope i could describe my problem properly...

im creating an appointment notification website using drupal 7. i used a custom content type called "appointment" that is shown only to the user relevant to the appointment (im "tagging" the user in the node with entity reference module and restricting the node view only to that user with the Node access user reference module).

the system is also supposed to notify users on upcoming appointments by SMS. i managed to get the sms framework and the rules module to trigger the sms submission prior to the date of the appointment to a predefined number.

so far, so good. my problem is -

the user has an optional profile field called "field_cellnumber" to fill out if he is interested in getting notifications to his phone... i want rules to check if the user has filled out that field, and only if so to trigger the sms submission. how could i achieve this? i tried going over all of the options in rule's "conditions" and did not find anything that could refer to the existence specific information in user profiles...

also, another problem is this - the field "field_cellnumber" is shared between the "appointment" node type and the user profiles (i created the field in the node type and then added to the user accounts by add existing field). while new "appointment" nodes are being created, i want drupal to fetch the value of "field_cellnumber" from the profile of the user that was referenced in the node by entity reference, and populate it into the node's "field_cellnumber" value automatically. right now the rule send's the sms but you need to manually enter the user's cell number each time creating a node which is quite a hassle. i aspire to get to a point where "tagging" the user would get his contact information automatically assigned to the node.

im quite new to drupal, so i would very much appreciate any pointers \ google reading references on how to achieve these two goals. thanks a lot, i am looking forward for your answers as i got along quite nicely so far but now i got stuck.

1
Welcome To SO. Ben, i suggest you trim your explanation down. There are not many, who will bother with reading a novel WITHOUT any source-code on SO. Stay concrete. Show what you have tried so far and explain what you would like to achive with pseudo-code. And try to ask just a single question per post.Don Question
thank you for your sincere answer... basically it's simple and have no code... i have a field called "field_cellphone" appearing both in a node content type called "appointments" and in the user profiles. also inside the node, there's a entity reference field that enables to "tag" a user in the node... let's say im creating a node and reference it to the user X. i want drupal to take the value of the "cellphone" field from his profile and set the it as the "cellphone" field value of that node... how can i do that? thanks a lot againDataB

1 Answers

3
votes

This is a perfect use case for entity reference and Rules can do this.

There is an action, load entity by ID (or similar name) that you need to perform before accessing any field of the entity. So, if you have the phone number in a node or profile2 field, you need to load that first.

To access further nodes through entity references,you will need to load each node. There is a condition to check if the field is empty.

So far, as I understand the question, you will need to do this.

  1. Trigger this on a scheduled Rule or some event.
  2. Load the user account by author ID. (load entity)
  3. Load the profile (load entity).
  4. Now, use data selector correctly to get the value of the entity loaded in #3.
  5. Set value of the entity available from #1 event (appointment node).
  6. Save the node from #5.

Good luck!