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);
});
To see the deletedRecordInConnect table, you must enable the NetSuite Analytics Warehouse feature at Setup > Company > Setup Tasks > Enable Features. For more information, see NetSuite Analytics Warehouse Overview.
The preceding code sample searches for deleted records that represent custom fields (where 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 support deletion tracking, as described in Searching for Deleted Records. If you use a string for a record type that isn't supported for deletion tracking, the query doesn't return any results
The preceding code sample also uses the UPPER() function to convert record type strings to uppercase before comparing them. Record type strings may have inconsistent casing. For example, the customfield record type string may appear as customField or CustomField when it's retrieved from the database. 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 get the same results, using SuiteAnalytics Connect. For more information, see Using SuiteQL with the Connect Service.