Overview

Total summ of specific field of filtered records.

Summary

This endpoint will return total sum based on specific field and records filtered by an expression. The filter can be applied to multiple fields and have multiple and/or conditions in it. Alternatively, you may use an existing filter by specifying its id. If both a filter definition and a filter id are passed, the two filters will be joined with an AND. Care will need to be taken to make sure that any filters used have appropriate indexes on the server side otherwise the runtime of the endpoint will be very long. Related fields can be searched by specifying the field name as: "link_name.remote_field", so if you wished to search the Accounts module by a related member account you would use "members.sic_code".

Request Arguments

Name Type Description Required
sumField String The DB field name to sum. True
filter String The filter expression. Filter expressions are explained below. Note that JSON-encoded filters can be specified as query parameters in one of two ways for GET requests:
  1. By specifying individual filter arguments as distinct parameters. Example: filter[0][id]=1.
  2. By specifying the whole filter as a single JSON-encoded string. Note that this syntax is currently not supported on certain modules. Example: filter=[{"id":"1"}].
False
filter_id String Identifier for a preexisting filter. If filter is also set, the two filters are joined with an AND. False
max_num Integer A maximum number of records to return. Default is 20. False
offset Integer The number of records to skip over before records are returned. Default is 0. False
fields String Comma delimited list of fields to return. Each field may be represented either by string, or by map containing field name and additional field parameters (applicable to link and collection fields). The fields id and date_modified will always be returned.
Example: name,account_type,description,{"name":"opportunities","fields":["id","name","sales_status"],"order_by":"date_closed:desc"}
For more details on additional field parameters, see Relate API and Collection API.
False
view String Instead of defining the fields argument, the view argument can be used instead. The field list is constructed at the server side based on the view definition which is requested. This argument can be used in combination with the fields argument. Common views are "record" and "list".
Example: record
False
order_by String How to sort the returned records, in a comma delimited list with the direction appended to the column name after a colon.
Example: name:DESC,account_type:DESC,date_modified:ASC
False
q String A search expression, will search on this module. Cannot be used at the same time as a filter expression or id. False
deleted Boolean Boolean to show deleted records in the result set. False
nulls_last Boolean Boolean to return records with null values in order_by fields last in the result set. False

Sum Filter Expressions

This will filter the results by checking the field "name" for value "Nelson Inc" and count a summ of amount field.
Example
{
   "sumField": "amount",
   "filter":[
      {
         "name":"Nelson Inc"
      }
   ]
}

Response Arguments

Name Type Description
sum_by_field Float The sum of the field values.
field_type String The type of the field.

Response

{
    "sum_by_field":63921.988303,
    "field_type":"currency"
}

Change Log

Version Change
v11_20 Added /<module>/total GET endpoint.