ssossossossosso

Forums

Covering OroCRM topics, including community updates and company announcements.  Subscribe

Forums OroCRM How to filter by group ids in "/api/contacts" endpoint in REST JSON API?

This topic contains 9 replies, has 2 voices, and was last updated by  Yurii Muratov 1 month ago.

  • Creator
    Topic
  • #79237

    spyout98
    Participant

    In Oro Rest Json API (“/api/doc/rest_json_api”), there is an endpoint “/api/contacts” with some fields and filters (see below):

    asd

    But I want to fetch all contacts that belongs to groups with some ids (one or more). For example: Show all contacts that belongs to group with id 1, Show all contacts that belongs to group with id 1 AND 2. But there is not a ‘filter[contactgroups]’ enabled in this endpoint.

    How do I enable the filters of groups/contactgroups?

Viewing 9 replies - 1 through 9 (of 9 total)
  • Author
    Replies
  • #79238

    spyout98
    Participant

    I am using OroCRM 2.6.17

    #79239

    spyout98
    Participant

    ?

    #79250

    spyout98
    Participant

    Any news?

    #79253

    Yurii Muratov
    Participant

    Hi @spyout98.

    The filters by to-many associations are not enabled by default. It is known issue and we are going to fix it soon.
    Fo now to enable the filter by the contact group you can add the following config in Resources/config/oro/api.yml of any of your bundle:

    After that run cache:clear CLI command.

    #79262

    spyout98
    Participant

    This filter enables the filter ‘group’ with which of these options below?:

    1. – only one group ID
    2. – many group IDS with criteria ANY
    3. – many group IDS with criteria AND

    How do I fill the filter to filter in option 1, 2 and 3?

    #79274

    Yurii Muratov
    Participant

    Hi @spyout98.

    You can set one or several ids for the filter ‘groups’. In case if several ids was set, the ANY criteria is used.

    In case if you need AND criteria, you need to create own type of filter. As example you can see ‘primaryField’ filter:

    https://github.com/oroinc/platform/blob/2.6/src/Oro/Bundle/ApiBundle/Filter/PrimaryFieldFilter.php
    https://github.com/oroinc/platform/blob/2.6/src/Oro/Bundle/ApiBundle/Resources/config/oro/app.yml#L80-L81
    https://github.com/oroinc/crm/blob/2.6/src/Oro/Bundle/ContactBundle/Resources/config/oro/api.yml#L36-L40

    #79280

    spyout98
    Participant

    Thanks for feedback, Yurii! To set multiple IDS, I need to fill the filter as “1,2,3” or “[1,2,3]”?

    #79290

    spyout98
    Participant

    ?

    #79291

    Yurii Muratov
    Participant

    Hello, @spyout98.

    The value should be “1,2,3”.

    Several values for a filter should be delimited by comma, without any additional symbols and spaces.
    More information about filters you can find in https://oroinc.com/b2b-ecommerce/doc/1.6/dev-guide/web-api#filters.

Viewing 9 replies - 1 through 9 (of 9 total)

You must be logged in to reply to this topic.

You will be redirected to [title]. Would you like to continue?

Yes No
ssossossossosso