a client script runs a search of a custom record a...
# suitescript
a
a client script runs a search of a custom record and returns the values. the custom record is set to "no permission required" (aka public) so this has always worked even for users in employee center role triggering the script. however as of today (after our 2022.2 release upgrade), there is now an "insufficient permission" error being returned when the script attempts to run the search for a user in an employee center role. has anyone run into this/know if it can be resolved any way other than creating a suitelet running as admin to perform the search? the whole point of using a public custom record was to avoid the suitelet route so i'd like to avoid it still if possible.
b
what does the script look like
a
Copy code
function validateLineExpenseEntry_classifications(type, name){
    if(nlapiGetRecordType() == "expensereport"){
        if(type == "expense"){
            var customer = nlapiGetCurrentLineItemValue("expense", "customer");
            if(customer){
                var filters = [];
                //see if there is a custom linked project fields record where comments are required. we're using a custom record because not many people will have permission to view projects directly and client side code runs in the context of the users role
                filters.push(new nlobjSearchFilter("custrecord_linked_project", null, "anyof", customer));
                var columns = [];
                columns.push(new nlobjSearchColumn("custrecord_class"));
                columns.push(new nlobjSearchColumn("custrecord_location"));
                columns.push(new nlobjSearchColumn("custrecord_department"));
                columns.push(new nlobjSearchColumn("custrecord_type"));

                var results = nlapiSearchRecord("customrecord_public_fields", null, filters, columns);
                if(results){
                    var projClass = results[0].getValue("custrecord_class");
                    var projLoc = results[0].getValue("custrecord_location");
                    var projDepartment = results[0].getValue("custrecord_department");
                    if(projClass){
                        nlapiSetCurrentLineItemValue("expense", "class", projClass, false, true);
                    }
                    if(projLoc){
                        nlapiSetCurrentLineItemValue("expense", "location", projLoc, false, true);
                    }
                    if(projDepartment){
                        nlapiSetCurrentLineItemValue("expense", "department", projDepartment, false, true);
                    }
                }
            }
        }
    }
    return true;
}
it's an old 1.0 script, and i removed some stuff for anonymization so if there are like, missing brackets or something that's probably why - it works as expected in our sandbox which has not been upgraded.
b
works for me
c
Whats the deployment look like? Is it only running for that one role? You could always change it to admin if you keep getting errors since its a "public" record anyways until you can narrow it down.
a
unfortunately since it’s a client script I don’t have the option to have it run “as” admin; if you meant just to disable the script for everyone except admin we can do that, but then the script won’t execute for most of our users entering expense reports so the classifications will be incorrect (that’s what the script’s purpose is).
c
I failed at reading sorry its a client script. You have it setup how I would do it. May need to open a case w/ NetSuite to see whats going on if something did in fact change on their end.