Skip to content
GitLab
Projects Groups Topics Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
  • E emailapi
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributor statistics
    • Graph
    • Compare revisions
  • Issues 5
    • Issues 5
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 1
    • Merge requests 1
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Extensions
  • emailapi
  • Merge requests
  • !9

location tokens should return primary location type

  • Review changes

  • Download
  • Email patches
  • Plain diff
Merged JonGold requested to merge JonGold/emailapi:primary-location-tokens into master Apr 14, 2020
  • Overview 1
  • Commits 1
  • Pipelines 0
  • Changes 1

Using location tokens with the Email API extension is non-deterministic; e.g. using the {contact.street_address} when the contact has multiple addresses will return one semi-randomly. We should always return the primary address/email/phone.

My change adds the default values for all the arguments to CRM_Contact_BAO_Query::apiQuery() except the last, which is $primaryLocationOnly. CRM_Contact_BAO_Query::apiQuery() generates a SQL query, then returns the results of that query. On my test contact, I had 4 phone numbers, 4 emails, and 5 addresses - the query returns 80 (445) results, except it's limited to the first 25. It then returns the 25th result. So e.g. adding a phone number can change the address returned.

This patch is both more performant (we only go once through the while loop) and will always return the primary location types.

Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: primary-location-tokens