mirror of
https://github.com/SuiteCRM/SuiteCRM.git
synced 2026-03-02 19:16:58 -05:00
V8 API: unable to filter on custom fields #4726
Labels
No labels
Area: API
Area: Campaigns
Area: Cases
Area: Clean Up
Area: Clean Up: Performance
Area: Dashlets
Area: Databases
Area: Developer Tools
Area: Elasticsearch
Area: Elasticsearch
Area: Emails
Area: Emails:Campaigns
Area: Emails:Cases
Area: Emails:Compose
Area: Emails:Config
Area: Emails:Templates
Area: Environment
Area: Installation
Area: Language
Area: Mobile
Area: Module
Area: PDFs
Area: PHP8
Area: Reports
Area: Studio
Area: Styling
Area: Upgrading
Area: Workflow
Area:Activity Stream
Area:Calls
Area:Import
Area:Projects
Area:Search
Area:Surveys
Area:Themes
Area:Users
Branch:Hotfix
Good First Issue
Hacktoberfest
Help Wanted
PR:Community Contribution
PR:Type:Enhancement
Priority:Critical
Priority:Important
Priority:Moderate
Severity: Major
Severity: Minor
Severity: Moderate
Status: Requires Code Review
Status: Requires Updates
Status: Stale
Status: Team Investigating
Status:Assessed
Status:Fix Proposed
Status:Needs Assessed
Status:Requires Automated Tests
Type: Bug
Type:Deprecated
Type:Discussion
Type:Duplicate
Type:Invalid
Type:Question
Type:Suggestion
Type:Suggestion
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/SuiteCRM-SuiteCRM#4726
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @Lehnerr on GitHub (Feb 3, 2022).
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
@Vagos91 commented on GitHub (Feb 5, 2022):
Same issue here in 7.11.22, any way for a temporary fix? Tried some solutions found in older threads but nothing worked, it keeps searching in the non _cstm table.
Edit: Updated to 7.12.3, not fixed. Still no solution seems to work for me.
@serfreeman1337 commented on GitHub (Mar 1, 2022):
Already fixed as of v7.12.0 and v7.11.20. Related issue https://github.com/salesagility/SuiteCRM/issues/7285 . You should replace your Api/V8/JsonApi/Repository/Filter.php file from the hotfix branch to have both OR and custom fields filters fixed.
@holdusback commented on GitHub (Apr 5, 2022):
I still have my issue in 7.12.5
->
Still no fix on this ?
I got this exact same error, but the API filter work lol
Im filtering a field in a form to check if the client is already in the database of suitecrm, the filter work like a charm, it just every call create error in the log …
The call look like Api/V8/module/Accounts?filter[siren_c][eq]=‘XXXX’
In generate in suitecrm.log :
Tue Apr 5 12:14:29 2022 [71911][1][FATAL] Mysqli_query failed.
Tue Apr 5 12:14:29 2022 [71911][1][FATAL] Query Failed: SELECT COUNT(*) AS cnt FROM accounts WHERE (accounts_cstm.siren_c = ‘XXXX’) AND accounts.deleted = ‘0’: MySQL error 1054: Unknown column ‘accounts_cstm.siren_c’ in ‘where clause’
The error are created everytime, if the filter return value or not. So its pretty much a bug
So its not really a big issue but this form is used a lot so it generate a bunch of useless line in the suitecrm.log.
I hope someone can help, if needed I will create an issue
@holdusback commented on GitHub (Aug 31, 2022):
Just as an update... This error still happen 7.12.7
I have request to the API everyday, so this make my log grow up insanely fast, the thing is that the API filter work well, I don't even know what this error mean.
@serfreeman1337 commented on GitHub (Aug 31, 2022):
Try to replace countRecords function in the Api/V8/BeanDecorator/BeanManager.php file with this:
@holdusback commented on GitHub (Sep 1, 2022):
Thank you ! Look like I dont have anymore the error in my log. So it look like to fix my (this ?) issue.
Since its not upgrade safe, I will have to make this change on every update right ? IDK if they will merge your fix.
Anyway thanks a lot !