Question/Problem:
Answer/Solution:
A. Create a Saved Employee Search in NetSuite UI that returns Login Audit Trail's Date, IP Address, Role in Results tab.
Accessing Login Audit Trail Search using SuiteScript
Answer/Solution:
A. Create a Saved Employee Search in NetSuite UI that returns Login Audit Trail's Date, IP Address, Role in Results tab.
1. Navigate to Lists > Employee > Search
2. Click Create Saved Search Button
2.1 Enter Search Title
2.2 Enter Search ID
3. Click Results Subtab to add the following columns:
3.1 Name
3.2 Login Audit Trail : Date
3.3 Login Audit Trail : IP Address
3.4 Login Audit Trail : Role
B. Sample script to retrieve saved search data using nlapiSearchRecord
var results = nlapiSearchRecord('employee', 'customsearch_emp_login', null, null);
for(var i=0; results!= null && i < results.length; i++)
{
var res = results[i];
var loginDate = res.getValue('date', 'loginaudittrail');
var loginIP = res.getValue('ipaddress', 'loginaudittrail');
var loginRole = res.getValue('role', 'loginaudittrail');
nlapiLogExecution('Debug', 'Process Log', 'Date - Login: ' + loginDate);
nlapiLogExecution('Debug', 'Process Log', 'IP - Login: ' + loginIP);
nlapiLogExecution('Debug', 'Process Log', 'Role - Login: ' + loginRole);
}
Note:
Enhancement Request #188929 was filed to have searching API's (nlapiSearchRecord and nlapiSearchGlobal) support Login Audit Trails
2.1 Enter Search Title
2.2 Enter Search ID
3. Click Results Subtab to add the following columns:
3.1 Name
3.2 Login Audit Trail : Date
3.3 Login Audit Trail : IP Address
3.4 Login Audit Trail : Role
B. Sample script to retrieve saved search data using nlapiSearchRecord
var results = nlapiSearchRecord('employee', 'customsearch_emp_login', null, null);
for(var i=0; results!= null && i < results.length; i++)
{
var res = results[i];
var loginDate = res.getValue('date', 'loginaudittrail');
var loginIP = res.getValue('ipaddress', 'loginaudittrail');
var loginRole = res.getValue('role', 'loginaudittrail');
nlapiLogExecution('Debug', 'Process Log', 'Date - Login: ' + loginDate);
nlapiLogExecution('Debug', 'Process Log', 'IP - Login: ' + loginIP);
nlapiLogExecution('Debug', 'Process Log', 'Role - Login: ' + loginRole);
}
Note:
Enhancement Request #188929 was filed to have searching API's (nlapiSearchRecord and nlapiSearchGlobal) support Login Audit Trails
No comments:
Post a Comment