+ $cidRefs[$customValueTables->table_name][] = 'entity_id';
+ }
+ }
+
+ /**
+ * Add custom ContactReference fields to the list of contact references
+ *
+ * This includes active and inactive fields/groups
+ *
+ * @param array $cidRefs
+ *
+ * @throws \CiviCRM_API3_Exception
+ */
+ public static function appendCustomContactReferenceFields(&$cidRefs) {
+ $fields = civicrm_api3('CustomField', 'get', [
+ 'return' => ['column_name', 'custom_group_id.table_name'],
+ 'data_type' => 'ContactReference',
+ ])['values'];
+ foreach ($fields as $field) {
+ $cidRefs[$field['custom_group_id.table_name']][] = $field['column_name'];