Accurate Employee data is fundamental to maintaining a secure, efficient, and well-governed NetSuite environment. One of the most critical data points in an Employee record is the email address, as it directly impacts system notifications, approval workflows, password resets, and overall communication processes.
From a Administrator’s perspective, missing or outdated email addresses can lead to failed workflow routing, missed alerts, and potential security risks. Whether you are preparing for a system audit, onboarding new employees, validating data before a mass update, or troubleshooting notification issues, having visibility into which employee records contain empty or populated email fields is essential.
In this article, we will use SuiteScript 2.x to quickly audit Employee records and identify which users have empty or populated email addresses—helping administrators maintain clean and reliable data.
Sample Scheduled Script: List Employees With and Without Email Addresses
/**
* @NApiVersion 2.x
* @NScriptType ScheduledScript
*/
define(['N/search', 'N/log'], function(search, log) {
function execute(context) {
// Arrays to store employee details based on email presence
var emptyEmailEmployees = [];
var nonEmptyEmailEmployees = [];
// Search for all active employees and get internal ID, name, and email
var employeeSearch = search.create({
type: search.Type.EMPLOYEE,
filters: [], // Add additional filters as needed
columns: [
'internalid',
'entityid',
'email'
]
});
// Run the search in pages to handle large datasets
var pagedResults = employeeSearch.runPaged({ pageSize: 1000 });
// Iterate through each page of results
pagedResults.pageRanges.forEach(function(pageRange) {
var page = pagedResults.fetch({ index: pageRange.index });
// Loop through each employee in the page
page.data.forEach(function(result) {
var internalId = result.getValue({ name: 'internalid' });
var entityId = result.getValue({ name: 'entityid' });
var email = result.getValue({ name: 'email' });
if (!email) {
// Employee has no email address
emptyEmailEmployees.push({
id: internalId, name: entityId
});
} else {
// Employee has an email address
nonEmptyEmailEmployees.push({
id: internalId, name: entityId, email: email
});
}
});
});
/// Log the list of employees without email addresses
log.audit('Empty Email Employees', JSON.stringify(emptyEmailEmployees));
// Log the list of employees with email addresses
log.audit('Non-Empty Email Employees', JSON.stringify(nonEmptyEmailEmployees));
// Log a summary of the results
log.audit('Summary',
'Total without email: ' + emptyEmailEmployees.length +
' | Total with email: ' + nonEmptyEmailEmployees.length
);
}
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!