Searching for Deleted Records That Use the New Analytics Data Source

You can retrieve information about deleted records that use the new analytics data source by using a SuiteQL query. SuiteQL is a query language that provides advanced query capabilities you can use to access your NetSuite records and data. You can run SuiteQL queries using the N/query module in SuiteScript. You can also run SuiteQL queries against NetSuite database tables directly using SuiteAnalytics Connect. For more information, see SuiteQL.

The following code sample shows how to run a SuiteQL query for deleted records using the N/query module in SuiteScript. You can reference the deletedRecordInConnect table, which contains information for deleted records.

          require(['N/query'], function(query) {
    var results = query.runSuiteQL({   
         query: "SELECT * FROM deletedRecordInConnect WHERE UPPER(recordType) = UPPER('customfield')"
    }).asMappedResults();

    log.debug(results);
}); 

        
Note:

To see the deletedRecordInConnect table, the NetSuite Analytics Warehouse feature must be enabled at Setup > Company > Setup Tasks > Enable Features. For more information, see NetSuite Analytics Warehouse Overview.

The preceding code sample queries for deleted records that represent custom fields (that is, the recordType value is customfield). For a list of record type strings you can use in this query, see query.Type. You can use strings for only those record types that are supported for deletion tracking, as described in Searching for Deleted Records. If you use a string for a record type that is not supported for deletion tracking, the query returns zero results.

The preceding code sample also uses the UPPER() function to convert record type strings to uppercase before comparing them. The casing of record type strings may not always be consistent. For example, the customfield record type string may appear as customField or CustomField when it is retrieved from the database. Using the UPPER() function ensures that the casing is consistent before comparison occurs. For more information about functions you can use in SuiteQL queries, see SuiteQL Supported and Unsupported Functions.

For more information about running SuiteQL queries using SuiteScript, see Using SuiteQL with the N/query Module in SuiteScript.

You can run the same SuiteQL query, and obtain the same results, using SuiteAnalytics Connect. For more information, see Using SuiteQL with the Connect Service.

Related Topics

Searching for Deleted Records
Searching Deleted Records That Use the Old Data Source

General Notices