Skip to content

V8 API: unable to filter on custom fields #9493

Open
@Lehnerr

Description

@Lehnerr

Issue

I've requesting a Contact with filtering on a custom field.
I get database error as result

Expected Behavior

I'm expecting that the filter is also working on custom fields and not only on standard fields

Actual Behavior

Request:
https://DOMAIN/crm/Api/V8/module/Contacts?fields[Contacts]=id,name,first_name,last_name,phone_mobile,phone_work&filter[operator]=or&filter[ctx_mobile_c][eq]=00439999999

Ends in SQLError:

Thu Feb 3 19:10:17 2022 [62233][1][FATAL] Mysqli_query failed.
Thu Feb 3 19:10:17 2022 [62233][1][FATAL] Query Failed: SELECT COUNT(*) AS cnt FROM contacts WHERE (contacts.ctx_mobile_c = '00436642304526') AND contacts.deleted = '0': MySQL error 1054: Unknown column 'contacts.ctx_mobile_c' in 'where clause'
T

Possible Fix

correct query to use join _cstm Table

Steps to Reproduce

1.create custom filed in contacts
2.create contact and fill custom field.
3.query the API
4.

Context

Your Environment

  • SuiteCRM Version used: 7.12.2
  • Browser name and version (e.g. Chrome Version 51.0.2704.63 (64-bit)):
  • Environment name and version (e.g. MySQL, PHP 7): php7.3
  • Operating System and version (e.g Ubuntu 16.04): ubuntu 20

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area: APIIssues & PRs related to all things regarding the APIPriority:ImportantIssues & PRs that are important; broken functions, errors - there are workaroundsType: BugBugs within the core SuiteCRM codebase

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions