I'm new to scripting and NetSuite so excuse my ignorance. I have searched both NetSuite help and the user group, but did not find anything relevant to what I am trying to accomplish. The script below is using the nlapiGetUser to lookup the employee firstname and lastname. I am currently just trying to display that information in an alert (eventually storing it in a custom field). The alert is returning undefined for both the firstname and lastname. What am I missing? Thanks for looking and any suggestions!
var userName = nlapiGetUser();
var filters = new Array();
filters[0] = new nlobjSearchFilter('internalid', null, 'is', userName, null);
var columns = new Array();
columns[0] = new nlobjSearchColumn('firstname');
columns[1] = new nlobjSearchColumn('lastname');
var searchResults = nlapiSearchRecord('employee', null, filters, columns);
for (var i = 0; searchResults != null && i < searchResults.length; i++)
{
var searchResult = searchResults[i];
var firstName = searchResult.getText('firstname');
var lastName = searchResult.getText('lastname');
}
alert("Employee ID: " + userName + " = " + firstName + " " + lastName);