The following code works fine for the Administrator, but throws the following error for users in other roles.
SSS_INVALID_SRCH_FILTER
An nlobjSearchFilter contains invalid search criteria:
custrecord_pto_employee
I have a Custom Record that when an employee creates a new request for Time Off, I want it to sum up all the time off that they've already requested and deduct it from the their yearly allotment. Additionally, employees only earn vacation days on a quarterly basis, so I'd like to parse the current date and give them 1/4 of their vacation time if in first quarter, 1/2 if in second quarter, etc. I don't see any NetSuite supported date functions to parse out the month from the current date.
var filters = new Array(); filters[0] = new nlobjSearchFilter('custrecord_pto_employee', null, 'is', nlapiGetFieldValue('custrecord_pto_employee') ); var columns = new Array(); columns[0] = new nlobjSearchColumn( 'custrecord_pto_vhours_requested' ); var searchresults = nlapiSearchRecord( 'customrecord_pto_request', null, filters, columns ); var vtotal = 0 for ( var i = 0; searchresults != null && i < searchresults.length; i++ ) { var searchresult = searchresults[ i ]; var record = searchresult.getId( ); var rectype = searchresult.getRecordType( ); var vhours = searchresult.getValue( 'custrecord_pto_vhours_requested' ); vtotal += 1 * vhours }