Uploaded image for project: 'CiviCRM'
  1. CiviCRM
  2. CRM-17096

A 'contains' operation for the api to search multiselect custom values.

    Details

    • Versioning Impact:
      Patch (backwards-compatible bug fixes)
    • Documentation Required?:
      Developer Doc
    • Sprint:
      4.7.10 api, 4.7.11 API
    • Funding Source:
      Needs Funding

      Description

      We have a multiselect custom field on relationships. Now I would like to use the API to retrieve e.g. all relationships where 'FI' is contained in the values selected for that custom fields. Something like this:

        $result = civicrm_api3('Relationship', 'get', array(
          'sequential' => 1,
          'custom_15' => array('CONTAINS' => 'FI'),
        ));
      

      I tried to do this:

        $result = civicrm_api3('Relationship', 'get', array(
          'sequential' => 1,
          'relationship_type_id' => 13,
          'custom_15' => array('LIKE' => '%' . CRM_Core_DAO::VALUE_SEPARATOR . "FI" . CRM_Core_DAO::VALUE_SEPARATOR . '%')
        ));
      

      But that did not work:

      CiviCRM_API3_Exception: [2001: '%' is not a valid option for field custom_15

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              johanv Johan Vervloet
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated: