Forums

Covering OroCommerce, OroCRM, OroPlatform topics, including community updates and company announcements.

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 6 months, 1 week ago.

  • Creator
    Topic
  • #30952

    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
  • #30953

    spyout98
    Participant

    I am using OroCRM 2.6.17

    #30954

    spyout98
    Participant

    ?

    #30955

    spyout98
    Participant

    Any news?

    #30956

    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.

    #30957

    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?

    #30958

    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

    #30959

    spyout98
    Participant

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

    #30960

    spyout98
    Participant

    ?

    #30961

    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
sso for www.magecore.comsso for oroinc.comsso for oroinc.desso for oroinc.fr