A filter specific to a Custom Field ID from List All Custom Field Value

Hello, everyone!

I’m trying to filter all values from a specific custom field. I noticed here in this link from api documentation that we can filter by dealId -> filters[dealId], but I don’t want to do a request for each deal, instead of do that, do a filter like: filters[customFieldId] would be nice. Or some possibility to do something like that.

2 Likes

If you want to search for a custom field value, the way to do it is different than through a typical /contacts call with filters. First you need the id of the custom field, which you can get by making a GET call to https://{{yourAccountName}}.api-us1.com/api/3/fields I have created a custom field called “Team Name,” and it appears like this in the /fields return:

        {
            "title": "Team Name",
            "descript": "The name of the team they are on",
            "type": "text",
            "isrequired": "1",
            "perstag": "TEAM-NAME",
            "defval": "Defaut Value",
            "show_in_list": "0",
            "rows": "0",
            "cols": "0",
            "visible": "1",
            "service": "",
            "ordernum": "16",
            "cdate": "2022-08-22T11:51:20-05:00",
            "udate": "2022-08-22T11:51:20-05:00",
            "created_timestamp": "2022-08-22 11:51:20",
            "updated_timestamp": "2022-08-22 11:51:20",
            "created_by": "1",
            "updated_by": "1",
            "options": [],
            "relations": [
                "55"
            ],
            "links": {
                "options": "https://yourAccountName.api-us1.com/api/3/fields/52/options",
                "relations": "https://yourAccountName.api-us1.com/api/3/fields/52/relations"
            },
            "id": "52"
        }

The id for this custom field is 52.

You can get the contact (or list of contacts) with the same value saved in a custom field by making a GET call to:
https://{{yourAccountName}}.api-us1.com/api/3/fieldValues?filters[fieldid]={{fieldId}}&filters[val]={{fieldValue}}&include=owner

For example, to retrieve a contact (or several contacts) that are on the same team, I now the following:

  • “team name” field id: 52
  • value I want to search for: Spiders

So my call looks like this:

GET: https://{{yourAccountName}}.api-us1.com/api/3/fieldValues?filters[fieldid]=52&filters[val]=Spiders&include=owner

If you want call of the contacts with a certain custom field written to it (let’s say id 52), just leave out the &filters[val]=Spiders part, and just have:

https://{{yourAccountName}}.api-us1.com/api/{{apiVersion}}/fieldValues?filters[fieldid]=52&include=owner

This will return the contacts, as well as objects like this:

You can see that contact 98 has field 52 populated with the team name Millsbury Reds
You can see that contact 99 has field 52 populated with the team name Spiders
You can see that contact 100 has field 52 not populated (not part of a team)

        {
            "contact": "98",
            "field": "52",
            "value": "Millsbury Reds",
            "cdate": "2022-08-22T12:00:07-05:00",
            "udate": "2022-08-22T12:01:36-05:00",
            "created_by": "0",
            "updated_by": "0",
            "owner": "98",
            "links": {
                "owner": "https://yourAccountName.api-us1.com/api/3/fieldValues/243/owner",
                "field": "https://yourAccountName.api-us1.com/api/3/fieldValues/243/field"
            },
            "id": "243"
        },
        {
            "contact": "99",
            "field": "52",
            "value": "Spiders",
            "cdate": "2022-08-22T12:27:39-05:00",
            "udate": "2022-08-22T12:28:20-05:00",
            "created_by": "0",
            "updated_by": "0",
            "owner": "99",
            "links": {
                "owner": "https://yourAccountName.api-us1.com/api/3/fieldValues/258/owner",
                "field": "https://yourAccountName.api-us1.com/api/3/fieldValues/258/field"
            },
            "id": "258"
        },
        {
            "contact": "100",
            "field": "52",
            "value": "",
            "cdate": "2022-08-22T12:30:46-05:00",
            "udate": "2022-08-22T12:30:46-05:00",
            "created_by": null,
            "updated_by": null,
            "owner": "100",
            "links": {
                "owner": "https://yourAccountName.api-us1.com/api/3/fieldValues/273/owner",
                "field": "https://yourAccountName.api-us1.com/api/3/fieldValues/273/field"
            },
            "id": "273"
        },

Thanks for your answer! This give me another idea.

However, I was talking about the custom fields from a deal, I wasn’t able to filter the deals that have a specific custom field. Do you know if there is any possibility to do that?

Thanks