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.
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-2 and so on.
Note the use of
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.