Answers.Body: <p>One possibility would be to use views module to create a view that displays auction package nodes, with a contextual filter for the contribution reference field. Then you provide a block display and configure the block to show on contribution pages; it should show the package that is referencing that contribution. </p>
  
  <p>This doesn't pull any Drupal entity data into the CiviCRM database, but it should allow you to <em>display</em> the entity data for the auction package that is referencing the contribution. </p>
  
  <p>Often times it is ideal to keep the Drupal entities in Drupal and the CiviCRM entities in CiviCRM and connect them using reference fields. You should still be able to display them side by side on the same page (using Views) in virtually any context or use-case.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-04-14T20:38:34.600Z
Answers.Text: I added a bit more about my reasoning behind this approach.
Answers.UserDisplayName: LunkRat
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-04-04T15:59:35.443Z
Answers.LastActivityDate: 2015-04-14T20:38:17.000Z
Answers.LastEditDate: 2015-04-14T20:38:17.000Z
Answers.UserDisplayName: LunkRat
Answers.Body: <p>This is a great question and frankly I've found it challenging to "seamlessly" integrate Drupal and Civicrm.  I have successfully used the Drupal Rules module and <a href="https://www.drupal.org/project/civicrm_entity" rel="nofollow">Civicrm Entity</a> to make Civicrm updates.  Alternatively, you can use the rule module and a PHP snippet to invoke the Civi API and make the update. </p>
  
  <p>The civicrm_entity / rules approach <a href="https://www.drupal.org/node/2316341" rel="nofollow">does not let you load multiple entities directly but you can use multiple referenced drupal entities</a>.</p>
  
  <p><a href="https://www.drupal.org/node/2380381" rel="nofollow">Civicrm_entity can also write fields directly</a> but you would have to write some code to edit the entity.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-04-14T23:19:36.030Z
Answers.Text: the issue mentioned in this comment has been resolved, there is a patch:https://www.drupal.org/node/2316341#comment-9800613 and the 2.x-dev download on D.O has this patch merged in
Answers.UserDisplayName: jackrabbithanna
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-04-19T02:43:44.663Z
Answers.Text: Ah ha, Rules! I think this is the answer I was looking for but I've held off on accepting it as I haven't managed to get it working yet. Maybe you all can help me figure out what I'm doing wrong? Here's my rule: Event: After updating Auction Package content (I'll need a second rule to fire after creating a node). Elements: Entity has field_i_want_to_copy_to_Civi & reference field. Actions: Loop through reference field. Fetch CiviCRM entity by property... um, now I'm doing something wrong - what do I do to update a field in the referenced CiviContribute records?
Answers.UserDisplayName: Kelley Curry
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-04-06T20:39:21.303Z
Answers.LastActivityDate: 2015-04-07T01:42:57.657Z
Answers.LastEditDate: 2015-04-07T01:42:57.657Z
Answers.UserDisplayName: Sonicthoughts
Answers.Body: <p>So my understanding of your use case is that you want to record in the back end in-kind donations related to items to be auctioned off in bundles. I assume that each item has its own valuation, and that you are mainly interested in getting a custom field on the contribution to reference an item. (I would guess the bundles of items are the sales side of the auction, and that multiple in-kind donations can be dealt with through separate contributions for each item.) Setting up contribution pages and price sets to reference the items in order to expose the items for auction would be something else again.</p>
  
  <p>I would make the custom field an integer, then in code on buildForm hook for the relevant form I would create a select widget that looked up the Drupal entity. If there were budget to improve usability in a minimal fashion I would add a link beside the field that creates a popup form to Add the Drupal entity, and on form close I would refresh the select lookup values. On view custom code needs to convert entity id into entity title or something, maybe an image and caption. If the value of the item is stored in Drupal then when it is selected I would use it overwrite the line item value in CiviCRM.</p>
  
  <p>A similar process could be used to link the donations corresponding to winning bids to the bundle entities that were won.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-04-07T01:59:03.780Z
Answers.LastActivityDate: 2015-04-07T04:17:59.300Z
Answers.LastEditDate: 2015-04-07T04:17:59.300Z
Answers.UserDisplayName: Joe Murray
Body: <p>I'm using Entity References and CiviCRM Entity to create some limited silent auction functionality. </p>
  
  <ul>
  <li>In CiviCRM, I have an "In-Kind" contribution type with some custom fields for each donation of an item to be auctioned off. </li>
  <li>In Drupal, I have an "Auction Package" content type for each group of one or more items that will be purchasable at auction. </li>
  <li>I created an entity reference field in the auction package so that you can select which items are part of each package. (So you could combine, say, a hotel's gift of a one-night stay with a restaurant's donated gift certificate.)</li>
  </ul>
  
  <p>So I've figured out how to pull CiviCRM information into Drupal. But is there a way to leverage the entity reference field in reverse to pull info from Drupal back into CiviCRM? I'd like to have a reference field in the contribution, or record the package number from the Drupal entity in the Civi contribution. How can I do this?</p>
  
  <p>Note: This is a new system, and I'm fairly new to CiviCRM, so I'm open to doing things differently if reworking anything about the way I have this set up would make this work better.</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-04-19T02:28:15.517Z
Comments.Text: 1) The referenced entity is a Civi Contribute gift record. 2)  At this point we're not trying to "sell" the Drupal auction package entities via CiviCRM (although that would be a cool future feature.) 3) My first choice would be a reverse reference field from Civi back to the Drupal node, but that didn't seem possible so we're settling for basically what you've said - a custom field on the CiviCRM record populated with info from a field (not the NID) on the "Auction Package" Drupal node.
Comments.UserDisplayName: Kelley Curry
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-04-19T14:38:59.793Z
Comments.Text: I think that's what you have to do, either with Rules or a custom Drupal module, update the CiviCRM data after the Drupal bit is created or updated.
Comments.UserDisplayName: jackrabbithanna
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-04-05T20:32:55.330Z
Comments.Text: What entity does your entity reference field reference? Are you using CiviCRM contribution page to sell these products?  Are you wanting to populate a custom field on the CiviCRM record with the node_id of the "Auction Package"?
Comments.UserDisplayName: jackrabbithanna
Tags: <civicontribute><drupal><civicrm-entity><entity-reference>
Title: Pull data from Drupal entity reference field into CiviCRM?
ThreadText: # Pull data from Drupal entity reference field into CiviCRM?
  
  (Asked by: username_0 on 2015-04-04)
  
  I'm using Entity References and CiviCRM Entity to create some limited silent auction functionality.
  
  * In CiviCRM, I have an "In-Kind" contribution type with some custom fields for each donation of an item to be auctioned off.
  * In Drupal, I have an "Auction Package" content type for each group of one or more items that will be purchasable at auction.
  * I created an entity reference field in the auction package so that you can select which items are part of each package. (So you could combine, say, a hotel's gift of a one-night stay with a restaurant's donated gift certificate.)
  
  So I've figured out how to pull CiviCRM information into Drupal. But is there a way to leverage the entity reference field in reverse to pull info from Drupal back into CiviCRM? I'd like to have a reference field in the contribution, or record the package number from the Drupal entity in the Civi contribution. How can I do this?
  
  Note: This is a new system, and I'm fairly new to CiviCRM, so I'm open to doing things differently if reworking anything about the way I have this set up would make this work better.
  
  **Tags:** civicontribute, drupal, civicrm-entity, entity-reference
  
  > **Comments:**
  > **username_1**: What entity does your entity reference field reference? Are you using CiviCRM contribution page to sell these products?  Are you wanting to populate a custom field on the CiviCRM record with the node_id of the "Auction Package"?  
  > **username_0**: 1) The referenced entity is a Civi Contribute gift record. 2)  At this point we're not trying to "sell" the Drupal auction package entities via CiviCRM (although that would be a cool future feature.) 3) My first choice would be a reverse reference field from Civi back to the Drupal node, but that didn't seem possible so we're settling for basically what you've said - a custom field on the CiviCRM record populated with info from a field (not the NID) on the "Auction Package" Drupal node.  
  > **username_1**: I think that's what you have to do, either with Rules or a custom Drupal module, update the CiviCRM data after the Drupal bit is created or updated.  
  
  ---
  
  ## 3 answers
  
  ### Answer by username_2 on 2015-04-04. Score: 3
  
  One possibility would be to use views module to create a view that displays auction package nodes, with a contextual filter for the contribution reference field. Then you provide a block display and configure the block to show on contribution pages; it should show the package that is referencing that contribution.
  
  This doesn't pull any Drupal entity data into the CiviCRM database, but it should allow you to *display* the entity data for the auction package that is referencing the contribution.
  
  Often times it is ideal to keep the Drupal entities in Drupal and the CiviCRM entities in CiviCRM and connect them using reference fields. You should still be able to display them side by side on the same page (using Views) in virtually any context or use-case.
  
  > **Comments:**
  > **username_2**: I added a bit more about my reasoning behind this approach.  
  
  ---
  
  ### Answer by username_3 on 2015-04-06. Score: 3
  
  This is a great question and frankly I've found it challenging to "seamlessly" integrate Drupal and Civicrm. I have successfully used the Drupal Rules module and [Civicrm Entity](https://www.drupal.org/project/civicrm_entity) to make Civicrm updates. Alternatively, you can use the rule module and a PHP snippet to invoke the Civi API and make the update.
  
  The civicrm\_entity / rules approach [does not let you load multiple entities directly but you can use multiple referenced drupal entities](https://www.drupal.org/node/2316341).
  
  [Civicrm\_entity can also write fields directly](https://www.drupal.org/node/2380381) but you would have to write some code to edit the entity.
  
  > **Comments:**
  > **username_1**: the issue mentioned in this comment has been resolved, there is a patch:https://www.drupal.org/node/2316341#comment-9800613 and the 2.x-dev download on D.O has this patch merged in  
  > **username_0**: Ah ha, Rules! I think this is the answer I was looking for but I've held off on accepting it as I haven't managed to get it working yet. Maybe you all can help me figure out what I'm doing wrong? Here's my rule: Event: After updating Auction Package content (I'll need a second rule to fire after creating a node). Elements: Entity has field_i_want_to_copy_to_Civi & reference field. Actions: Loop through reference field. Fetch CiviCRM entity by property... um, now I'm doing something wrong - what do I do to update a field in the referenced CiviContribute records?  
  
  ---
  
  ### Answer by username_4 on 2015-04-07. Score: 3
  
  So my understanding of your use case is that you want to record in the back end in-kind donations related to items to be auctioned off in bundles. I assume that each item has its own valuation, and that you are mainly interested in getting a custom field on the contribution to reference an item. (I would guess the bundles of items are the sales side of the auction, and that multiple in-kind donations can be dealt with through separate contributions for each item.) Setting up contribution pages and price sets to reference the items in order to expose the items for auction would be something else again.
  
  I would make the custom field an integer, then in code on buildForm hook for the relevant form I would create a select widget that looked up the Drupal entity. If there were budget to improve usability in a minimal fashion I would add a link beside the field that creates a popup form to Add the Drupal entity, and on form close I would refresh the select lookup values. On view custom code needs to convert entity id into entity title or something, maybe an image and caption. If the value of the item is stored in Drupal then when it is selected I would use it overwrite the line item value in CiviCRM.
  
  A similar process could be used to link the donations corresponding to winning bids to the bundle entities that were won.
  
  
  ---
  
  