Skip to main content

Filtering

The Public API has a powerful filtering system.

It allows you to filter either Cases, Companies or Persons.

The filtering system is currently only available for use with GraphQL.

In the code example, you can see how a basic use of it looks. Here we are filtering cases for any case named "test".

Each type filter is defined by its type, e.g. CaseFilters:

query getCases($amount: Int, $filters: [CaseFilters]) {
cases(amount: $amount, filters: $filters) {
items {
item {
id
name
}
}
}
}

variables: {
filters: {
{ name: { equals: "test" } }
}
}

We get the elements that matches the filter:

{
"data": {
"cases": {
"items": [
{
"item": {
"name": "test"
}
},
{
"item": {
"name": "test"
}
}
],
}
}
}

The syntax of these filters allows each field to have multiple filters.

The operators are string based and can be seen alongside the filter definitions.

The various filters are described underneath:

CaseFilters

NameTypeSupported operators
nameStringequals, notEquals
timeCreatedIntegerequals, notEquals, lessThan, greaterThan
timeLastEditedIntegerequals, notEquals, lessThan, greaterThan
externalIdStringThis has a special set of operators, and is explained in the next section. It looks up the related Persons and Companies as the cases do not have any externalIds.

CompanyFilters

NameTypeSupported operators
nameStringequals, notEquals
timeCreatedIntegerequals, notEquals, lessThan, greaterThan
timeLastEditedIntegerequals, notEquals, lessThan, greaterThan
externalIdStringThis has a special set of operators, and is explained in the next section

PersonFilters

NameTypeSupported operators
nameStringequals, notEquals
timeCreatedIntegerequals, notEquals, lessThan, greaterThan
timeLastEditedIntegerequals, notEquals, lessThan, greaterThan
externalIdStringThis has a special set of operators, and is explained in the next section

Special case: ExternalId

Again the filter syntax is almost the same, except for the externalId name and having two operators:

query getPersons($amount: Int, $filters: [PersonFilters]) {
persons(amount: $amount, filters: $filters) {
items {
item {
id
name
ExternalId_Vendor_Advosys_CustomerNumber
}
}
}
}

variables {
filters: {
{ externalId: { type: "ExternalId_Vendor_Advosys_CustomerNumber", in: ["1", "2", "3"] } }
}
}

We get the elements that matches the filter:

{
"data": {
"persons": {
"items": [
{
"item": {
"name": "test",
"ExternalId_Vendor_Advosys_CustomerNumber": ["1"]
}
},
{
"item": {
"name": "test",
"ExternalId_Vendor_Advosys_CustomerNumber": ["2"]
}
},
{
"item": {
"name": "test",
"ExternalId_Vendor_Advosys_CustomerNumber": ["3"]
}
}
]
}
}
}

The ExternalId filter allows API users to query cases persons or companies based on an id that is from another external system, like CVR or e-conomic.

It takes two operators that must both be present, the type, which is a string and an in-selection, which is an array of strings or integers.

Only Persons and Companies have ExternalIds. When filtering with this on cases, it looks into the related Persons and Companies of that case, and returns the case if matching relations were found.

Underneath you can see the ExternalIds that are currently supported by the API and the system:

NameDescription
ExternalId_Vendor_Advosys_CustomerNumberA customer number from the Unik Advosys System
ExternalId_Vendor_Economic_CustomerNumberA customer number from Visma e-conomic
ExternalId_DK_CVR_APIIdThe unique id in the CVR API for this item
ExternalId_DK_CVR_NumberThe CVR number of a company.