2

How do I perform Contact GET for the contact with the exact display name which will return only contacts with that exact display name?

Say I create two users xyz and xyzA

$result = civicrm_api3('Contact', 'create', array(
  'sequential' => 1,
  'contact_type' => "Individual",
  'display_name' => "xyz",
));

$result = civicrm_api3('Contact', 'create', array(
  'sequential' => 1,
  'contact_type' => "Individual",
  'display_name' => "xyzA",
));

The flowing get request always returns both contacts (xyz and xyzA)

$result = civicrm_api3('Contact', 'get', array(
  'sequential' => 1,
  'display_name' => "xyz",
));

I want my API call to return only users with a display name xyz. How would I do this?

There is an option to turn off Automatic Wildcard, but that would affect the entire website and all the users. Is there a way around this?

3

The Contact API is non-standard in APIv3; a major goal of APIv4 is to remove these quirks. The behavior you're seeing on Display Name is non-standard. It also seems that a lot of the other operators (e.g. "LIKE") don't work on Display Name.

If you can, you can search on First Name and/or Last Name, neither of which display the problem described here.

  • 1
    This explains a lot. I'll have to use a custom field which will mirror display name. Thanks! – Marko Jan 23 '18 at 14:28

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.