- Issue created by @sadashiv
- Status changed to Needs review
11 months ago 3:48pm 12 February 2024 - 🇺🇸United States markusa
What about:
$row->_entity->get('field_name')->target_id
- 🇮🇳India sadashiv
Yes, I tried that well and I get label i.e. display_name of the contact and not the contact id.
Thanks,
Sadashiv. - 🇺🇸United States markusa
Something like this may work too:
$contact = $row->_entity->get('field_reference')->entity; $contact_id = $contact->id();
Would you like to make a PR in the github repo as well? Primary development happens there at this time.
https://github.com/eileenmcnaughton/civicrm_entity/I feel it shouldn't be necessary, but perhaps I don't understand the situation exactly.
- 🇮🇳India sadashiv
I tried a slight modified version of your code snipped but no luck
$row->_entity->get('custom_147')->first()->get('entity') returns the entity but the target_id still has label.
I created a PR at https://github.com/eileenmcnaughton/civicrm_entity/pull/465
Thanks,
Sadashiv. - 🇺🇸United States markusa
Ok, i understand now .. a CiviCRM custom contact reference field :) I was thinking something else.
I'll play around and see what I can provide for a snippet, and/or experiment with this PR
- 🇮🇳India sadashiv
Any update on this, I want to deploy this change on production.
Thanks,
Sadashiv. - 🇺🇸United States markusa
It is always possible to add a patch with composer
The patch is available by adding ".patch" to the PR url
https://patch-diff.githubusercontent.com/raw/eileenmcnaughton/civicrm_en...So in the "extras" portion of composer.json
"patches": {
"drupal/civicrm_entity": {
"raw values fix": "https://patch-diff.githubusercontent.com/raw/eileenmcnaughton/civicrm_en..."
}
},Patches with composer requires cweagans/composer-patches
- Status changed to Fixed
8 months ago 7:49pm 25 April 2024 Automatically closed - issue fixed for 2 weeks with no activity.