Maintaining accurate customer email data is more important than it seems. Whether you are sending invoices, running marketing campaigns, or supporting integrations, missing or incorrect email addresses can lead to failed communications and operational issues.
While Saved Searches are great, there are times when admins need a quick, flexible way to review data directly from the system logs especially during troubleshooting or one-time audits. This tip shows how a simple Scheduled Script can help you quickly extract and review customer email information with minimal setup.
This script:
- Searches all Customer records.
- Retrieves:
- Customer Name/ID (entityid)
- Email Address (email)
- Logs each record in Execution Logs for review.
Sample Script
/**
* @NApiVersion 2.x
* @NScriptType ScheduledScript
*/
define(['N/search', 'N/log'], function (search, log) {
function execute(context) {
// Create a customer search
// This pulls basic customer identification and email information
var customerSearch = search.create({
type: search.Type.CUSTOMER,
// Define the columns (fields) we want to retrieve
columns: [
search.createColumn({
name: 'entityid', // Customer Name/ID
sort: search.Sort.ASC // Sort results alphabetically
}),
search.createColumn({
name: 'email' // Customer Email Address
})
]
});
// Run the search and loop through each result
customerSearch.run().each(function (result) {
// Log each customer record in a readable format
// Example output: "ABC Company | abc@email.com"
log.debug({
title: 'Customer Record',
details: result.getValue({ name: 'entityid' }) +
' | ' +
result.getValue({ name: 'email' })
});
// Return true to continue processing the next result
return true;
});
}
// Expose the execute function to NetSuite
return {
execute: execute
};
});
The sample code described herein is provided on an "as is" basis, without warranty of any kind, to the fullest extent permitted by law. Oracle + NetSuite Inc. does not warrant or guarantee the individual success developers may have in implementing the sample code on their development platforms or in using their own Web server configurations.
Oracle + NetSuite Inc. does not warrant, guarantee or make any representations regarding the use, results of use, accuracy, timeliness or completeness of any data or information relating to the sample code. Oracle + NetSuite Inc. disclaims all warranties, express or implied, and in particular, disclaims all warranties of merchantability, fitness for a particular purpose, and warranties related to the code, or any service or software related thereto.
Oracle + NetSuite Inc. shall not be liable for any direct, indirect or consequential damages or costs of any type arising out of any action taken by you or others related to the sample code.
To know more about deploying SuiteScript, check these New to NetSuite Articles.
Do you have another way on how to automate your transactions using SuiteScript? Feel free to share them here!