2

I have a Drupal view set up to display the CiviCRM address(es) related to a given contact:

Full view settings

Drupal view full settings

Query options

As a note, I have enabled the Distinct and Pure Distinct settings on the Drupal query settings:

Drupal view query settings showing Distinct and Pure Distinct enabled

CiviCRM contact page

On the CiviCRM contact page, there are only, for example, two unique addresses: CiviCRM Contact page showing two unique addresses

Duplicate addresses on Drupal view (caching?)

For some reason, the addresses are appearing multiple times on the Drupal view:

Drupal CiviCRM contact view showing duplicate addresses

How can I ensure that only distinct addresses are shown for a given contact?

  • Do you have any Views Relationships set? Can you post a screenshot of the full View, or provide the export code? – jackrabbithanna Jun 3 '17 at 17:45
  • Upon closer inspection, I realized all of the addresses are unique. For some reason, the zip code has been changed over time, or other minor changes have been made. How can I show only the latest revision? – Brylie Christopher Oxley Jun 6 '17 at 9:10
  • I don't believe there are address revisions, something else happening here. Pls post screenshot of complete View or the View export code so I can dig deep. – jackrabbithanna Jun 6 '17 at 15:23
  • I have added a full screenshot to the original question. Might this be some kind of Drupal caching issue? – Brylie Christopher Oxley Jun 7 '17 at 17:55
  • If you will notice. The only differences between the two versions of the Mailing and Worship addresses are that the street abbreviation "st" has an added period "st.". I thought there might be a revision stored somewhere, as the repeated addresses seem to be related to changes to the Address records. This is similarly evident on the Drupal view display, where the Albuquerwue addresses have had several minor changes including to the zipcode. – Brylie Christopher Oxley Jun 7 '17 at 20:37
3

If you can't sort the above out by ensuring you specify Location type (ie have a field for Zip = Worship, as well as Zip = Mailing) then I would try the views_field_view module.

I would make one view that pulls together the address details for just Worship, and another one that pulls together just the address for Mailing. Both these need to be set to use Contextual Filter = contact id. And set them both to only show 1 result

Then pull those both in as a Field and obviously use the contact_id as the contextual filter (also needs using on the two views you have to create)

  • 1
    Thanks petednz. The individual view per address type worked. I am still not sure what the underlying problem was, but your suggestion helped me to go forward. – Brylie Christopher Oxley Jun 19 '17 at 15:56
  • I am trying this solution out, but loading a view within a view can't be great for performance? It would be great to update the views integration code to work with address revisions? – Zachary May 29 '18 at 21:14
  • Agreed but you can use caches to reduce impact perhaps. And how many folk are likely to be hitting this concurrently? My colleague is also recommending always using the view Relationships to get the Address data rather than the in-built civi field. – petednz - fuzion May 29 '18 at 21:21
0

Make sure you select only the address where is_primary = 1

  • 1
    OR filter by location type = home, billing, work etc . – jitendra - fuzion Jun 3 '17 at 14:10
  • This seems related to address revisions. The addresses may have been updated over time, for example changing the zip code, and for some reason the view is showing all of the revisions. How can I configure it to show only the current revision? – Brylie Christopher Oxley Jun 6 '17 at 9:11
  • For what it's worth, we do want to display multiple address types on the view, but only the latest revision of each type. – Brylie Christopher Oxley Jun 6 '17 at 9:30
  • Has anyone figured out how to only show the most recent address revision? – Zachary May 29 '18 at 21:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.