Toggle menu

purgeRecords

Description

Deletes all records matching the supplied selectors. Returns a count of those purged.

Parameters

All are required.

NameTypeDescription
typeObjectSee Type
ageObjectSee Age
userObjectSee User
stateObjectSee State

Returns

PropertyTypeDescription
recordsPurgedintegerThe number of records deleted

Examples

Workflow

This example purges all workflow instances older than three months, in any state, that the supplied user interacted with in some way.

Request

function(params, credentials) {
    var records = this.callWorkerMethod("workflow", "purgeRecords", {
        "type": {
            "matchAll": true
        },
        "age": {
            "created": "P3M"
        },
        "user": {
            "involved": params.user
        },
        "state": {
            "matchAll": true
        }
    });
    return records;
}

Returns

{
    "jsonrpc": "2.0",
    "id": 241,
    "result": {
        "recordsPurged": 95
    }
}

History

This example deletes 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", "purgeRecords", {
        "type": {
            "labelA": "Online Auction",
            "labelC": null
        },
        "age": {
            "matchAll": true
        },
        "user": {
            "involved": params.user
        },
        "state": {
            "finished": true
        }
    });
    return records;
}

Returns

{
    "jsonrpc": "2.0",
    "id": 242,
    "result": {
        "recordsPurged": 16
    }
}

Objects

This example deletes 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", "purgeRecords", {
        "type": {
            "matchAll": true
        },
        "age": {
            "lastUpdated": "P3M"
        },
        "user": {
            "createdBy": params.user
        },
        "state": {
            "finished": false
        }
    });
    return records;
}

Returns

{
    "jsonrpc": "2.0",
    "id": 243,
    "result": {
        "recordsPurged": 11
    }
}

Last modified on 11 March 2020

Share this page

Facebook icon Twitter icon email icon

Print

print icon