Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
C
Core
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 916
    • Issues 916
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
  • Operations
    • Operations
    • Incidents
  • Analytics
    • Analytics
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Create a new issue
  • Commits
  • Issue Boards
  • Development
  • Core
  • Issues
  • #810

Closed
Open
Opened Mar 19, 2019 by Andrew West@awestbha

Non-primary details exported in primary-only exports, when the setting 'Search Primary Details Only' is set to 'no'

If you run an export with 'Export PRIMARY fields', but you have the setting 'Search Primary Details Only' set to 'No', the primary filter is not applied and you simply get the first available row in the table. This also happens when you select the 'Primary' option when exporting individual fields.

This definitely applies to postal addresses. I haven't tested emails but I think it'll happen there too.

It happens because of this line in CRM_Contact_BAO_Query: https://github.com/civicrm/civicrm-core/blob/a2540ad336faf7fb0218055a485c1a702200293f/CRM/Contact/BAO/Query.php#L446 which defaults to using the value from the setting. If this is set to no, the result SQL clause doesn't include 'is_primary = 1'.

CRM_Export_BAO_ExportProcessor creates the Query object here: https://github.com/civicrm/civicrm-core/blob/a2540ad336faf7fb0218055a485c1a702200293f/CRM/Export/BAO/ExportProcessor.php#L509 but doesn't pass through a value for 'primaryLocationOnly' to override the default setting.

I can presumably adapt the above to pass through primaryLocationOnly when users have selected the 'Export PRIMARY fields' option - that seems simple enough. I haven't had a chance to dig into how it works when the export specifies individual fields, though - that seems like it'd be more complicated.

To replicate on demo site:

  1. Create a new tmp group
  2. Find a contact with an existing primary address
  3. Add a new address for them, and set it to primary
  4. Add this contact to the tmp group
  5. Turn off the setting 'Search Primary Details Only'
  6. Search for all members of the tmp group, and export them using 'Export PRIMARY fields only'
  7. The contact's address in the CSV will be the original address, which is non-primary
Edited Mar 19, 2019 by Andrew West
To upload designs, you'll need to enable LFS and have admin enable hashed storage. More information
Assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking
None
Due date
None
Reference: dev/core#810