Answers.Body: <p>I got this working by installing the CiviCRM Rules and CiviCRM Entity modules in Drupal. I was then able to create a rule that would populate custom fields in the node author's CiviCRM individual contact record with values from the node when the node was created or updated. In my case, it was the node title, the node path, and a custom date field on the node.</p>
  
  <p>The key was to create a rule that would trigger on node create or edit, and then update each of the CiviCRM fields I wanted. The CiviCRM fields were accessible in Rules as <code>node:author:civicrm-contact:custom-1</code>, <code>node:author:civicrm-contact:custom-2</code> and so on.</p>
  
  <p>Note the use of <code>node:author</code> not <code>current:user</code> - I wanted the node:author record to be updated. Whilst these would be the same when the author creates/updates the node, they would be different if another user updated the node. If you use current:user, then the fields of the current user would be updated. I guess there is a use case where that would be desirable, but it wasn't what I wanted.</p>
  
  <p>I was then able to use Drupal's Admin Views module (which incorporates Views Bulk Operations) to carry out a bulk save on all the nodes that had been created prior to configuring this set-up - this triggered the rule and updated the individual field</p>
  
  <p>The only thing I haven't solved at this point is how to allow multiple instances of my custom field set in CiviCRM (i.e. to capture the fields for multiple nodes created by the same author). I initially configured the field set this way, but found that each save of a node added a new instance of the field set in the CiviCRM contact record rather than updating the existing field set. When I reverted to a single instance, the fields were simply updated on each save.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-09-01T14:08:26.163Z
Answers.Text: I wonder if you can create a node ID field in your custom fieldset that gets set by a rule on node create, and only the other fields get set (possibly with a second rule just for node edit) on edit only if the node ID matches the field? That may stop a new instance of the fieldset being created each time, but bear in mind it's just an untested idea.
Answers.UserDisplayName: Eli Lisseck
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-09-02T01:33:30.820Z
Answers.Text: I can see the potential for this idea. Pushing the NID across is just an extension of what I've already done ... you'd then need to create a loop in Rules to check each fieldset in turn, and update the fieldset where the NID matches...
Answers.UserDisplayName: millionleaves
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-09-01T05:01:48.840Z
Answers.LastActivityDate: 2016-09-01T05:01:48.840Z
Answers.UserDisplayName: millionleaves
Body: <p>I have a scenario where site users are able to create content in Drupal. Let's assume they will only ever create one node. Their details are in CiviCRM already since they have a Drupal user account, but I'd like to pass values from fields in the node (e.g. URL and the Title) of the node into custom fields in the node author's contact record in CiviCRM.</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-09-03T09:32:12.907Z
Comments.Text: Hi David - naive question perhaps, but do you actually need to push the data in to civicrm, or would it have been enough to use CiviCRM Node Reference, and just reference the civi id on the node, and then build a View that would show you all the nodes that are related to that Contact? Otherwise it seems you are storing data in two places.
Comments.UserDisplayName: petednz - fuzion
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-09-04T01:23:14.907Z
Comments.Text: Good question. The objective was to use the node title and path in Civimail. We also wanted to create a smart group based on the date field (all contacts with a start date from May 1 onwards). This was a quick solution that achieved what I needed relatively quickly, so I didn't go any further.
Comments.UserDisplayName: millionleaves
Tags: <drupal><civicrm-entity><civirules>
Title: How to pass field data from a Drupal node to the CiviCRM contact record of the author
ThreadText: # How to pass field data from a Drupal node to the CiviCRM contact record of the author
  
  (Asked by: username_0 on 2016-09-01)
  
  I have a scenario where site users are able to create content in Drupal. Let's assume they will only ever create one node. Their details are in CiviCRM already since they have a Drupal user account, but I'd like to pass values from fields in the node (e.g. URL and the Title) of the node into custom fields in the node author's contact record in CiviCRM.
  
  **Tags:** drupal, civicrm-entity, civirules
  
  > **Comments:**
  > **username_1**: Hi David - naive question perhaps, but do you actually need to push the data in to civicrm, or would it have been enough to use CiviCRM Node Reference, and just reference the civi id on the node, and then build a View that would show you all the nodes that are related to that Contact? Otherwise it seems you are storing data in two places.  
  > **username_0**: Good question. The objective was to use the node title and path in Civimail. We also wanted to create a smart group based on the date field (all contacts with a start date from May 1 onwards). This was a quick solution that achieved what I needed relatively quickly, so I didn't go any further.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2016-09-01. Score: 2
  
  I got this working by installing the CiviCRM Rules and CiviCRM Entity modules in Drupal. I was then able to create a rule that would populate custom fields in the node author's CiviCRM individual contact record with values from the node when the node was created or updated. In my case, it was the node title, the node path, and a custom date field on the node.
  
  The key was to create a rule that would trigger on node create or edit, and then update each of the CiviCRM fields I wanted. The CiviCRM fields were accessible in Rules as `node:author:civicrm-contact:custom-1`, `node:author:civicrm-contact:custom-2` and so on.
  
  Note the use of `node:author` not `current:user` - I wanted the node:author record to be updated. Whilst these would be the same when the author creates/updates the node, they would be different if another user updated the node. If you use current:user, then the fields of the current user would be updated. I guess there is a use case where that would be desirable, but it wasn't what I wanted.
  
  I was then able to use Drupal's Admin Views module (which incorporates Views Bulk Operations) to carry out a bulk save on all the nodes that had been created prior to configuring this set-up - this triggered the rule and updated the individual field
  
  The only thing I haven't solved at this point is how to allow multiple instances of my custom field set in CiviCRM (i.e. to capture the fields for multiple nodes created by the same author). I initially configured the field set this way, but found that each save of a node added a new instance of the field set in the CiviCRM contact record rather than updating the existing field set. When I reverted to a single instance, the fields were simply updated on each save.
  
  > **Comments:**
  > **username_2**: I wonder if you can create a node ID field in your custom fieldset that gets set by a rule on node create, and only the other fields get set (possibly with a second rule just for node edit) on edit only if the node ID matches the field? That may stop a new instance of the fieldset being created each time, but bear in mind it's just an untested idea.  
  > **username_0**: I can see the potential for this idea. Pushing the NID across is just an extension of what I've already done ... you'd then need to create a loop in Rules to check each fieldset in turn, and update the fieldset where the NID matches...  
  
  ---
  
  