Description
Returns a count of records matching the specified selectors.
Parameters
All are required.
Name | Type | Description |
---|---|---|
type | Object | See Type |
age | Object | See Age |
user | Object | See User |
state | Object | See State |
Returns
Property | Type | Description |
---|---|---|
count | integer | The number of records |
Examples
Workflow
This example counts all workflow instances of any age, in any state, that the supplied user interacted with in some way.
Request
function(params, credentials) {
var records = this.callWorkerMethod("workflow", "countRecords", {
"type": {
"matchAll": true
},
"age": {
"matchAll": true
},
"user": {
"involved": params.user
},
"state": {
"matchAll": true
}
});
return records;
}
Returns
{
"jsonrpc": "2.0",
"id": 175,
"result": {
"count": 120
}
}
History
This example counts histories that involved the supplied user, have a labela of "Online Auction" and are sealed. labelC is set as null so that any histories that have a value for labelc, like reporting or audit (following our reporting conventions described in Labelc Histories and Reporting Data) are excluded.
Request
function(params, credentials) {
var records = this.callWorkerMethod("history", "countRecords", {
"type": {
"labelA": "Online Auction",
"labelC": null
},
"age": {
"matchAll": true
},
"user": {
"involved": params.user
},
"state": {
"finished": true
}
});
return records;
}
Returns
{
"jsonrpc": "2.0",
"id": 177,
"result": {
"count": 16
}
}
Objects
This example counts objects of any type, created by the supplied user, that haven't been updated in the last three months.
Request
function(params, credentials) {
var records = this.callWorkerMethod("icmapi", "countRecords", {
"type": {
"matchAll": true
},
"age": {
"lastUpdated": "P3M"
},
"user": {
"createdBy": params.user
},
"state": {
"finished": false
}
});
return records;
}
Returns
{
"jsonrpc": "2.0",
"id": 188,
"result": {
"count": 89
}
}