we have one suitelet basically few fields, 5 butto...
# suitescript
r
we have one suitelet basically few fields, 5 button and a sublist. In setscript we are setting the id of suitelet itself, the function tied to all buttons are written in suitelet itself are used to populate the subsist values. It is working fine for everyone but for 1 user, it's throwing the error function_name is not defined depending upon the button used. Has someone faced something like this? finding it very strange.
b
what does the code look like
r
Copy code
function suitelet(request, response) {
	try {
		var method = request.getMethod();
		nlapiLogExecution('debug', 'method', method);
		if (method == "GET") {
			var projectId = request.getParameter('project');
			if (projectId) {
				renderProjectDetailsPage(projectId);
			}
			else {
				renderProjectSelectionPage();
			}
		}
		else {
			method = request.getParameter('custpage_next_step');
			nlapiLogExecution('debug', 'method', method);
			if (method == 'GoBack') {
				nlapiSetRedirectURL('SUITELET', '661', 'customdeploy_sut_project_wise_ta_ea', null, null);
			}
			if (method == "DisplayProjectDetails") {
				renderProjectDetailsPage(request);
			}
			else if (method == "SubmitProjectDetails") {
				renderResultPage(request);
			}
			else {
				renderProjectSelectionPage();
			}
		}
	}
	catch (err) {
		nlapiLogExecution('ERROR', 'suitelet', err);
	}
}
Copy code
function renderProjectDetailsPage(request) {
	try {
		var projectId = request;
		//var projectId = request.getParameter('custpage_project');

		if (projectId) {
			var getForm = nlapiCreateForm('Manager Change Form', false);

			// Project
			getForm.addFieldGroup('custpage_1', 'Selected Project');
			getForm.addField('custpage_project', 'select', 'Project', 'job',
				'custpage_1').setDisplayType('inline').setDefaultValue(
					projectId);

			var projectDetails = nlapiLookupField('job', projectId, [
				'custentity_projectmanager', 'custentity_deliverymanager',
				'custentity_clientpartner']);

			// Project Manager
			getForm.addFieldGroup('custpage_2', 'Project Manager');
			getForm.addField('custpage_pm_old', 'select', 'Old', 'employee',
				'custpage_2').setDisplayType('inline').setDefaultValue(
					projectDetails.custentity_projectmanager);
			getForm.addField('custpage_pm_new', 'select', 'New', 'employee',
				'custpage_2');

			// Delivery Manager
			getForm.addFieldGroup('custpage_3', 'Delivery Manager');
			getForm.addField('custpage_dm_old', 'select', 'Old', 'employee',
				'custpage_3').setDisplayType('inline').setDefaultValue(
					projectDetails.custentity_deliverymanager);
			getForm.addField('custpage_dm_new', 'select', 'New', 'employee',
				'custpage_3');

			// Client Partner
			getForm.addFieldGroup('custpage_4', 'Client Partner');
			getForm.addField('custpage_cp_old', 'select', 'Old', 'employee',
				'custpage_4').setDisplayType('inline').setDefaultValue(
					projectDetails.custentity_clientpartner);
			getForm.addField('custpage_cp_new', 'select', 'New', 'employee',
				'custpage_4');

			/*getForm.addFieldGroup('custpage_5', 'Expense/Time Approver');
			getForm.addField('custpage_all_expense', 'select',
					'New Expense Approver', 'employee',
					'custpage_5');
			getForm.addField('custpage_5_newta', 'select',
					'New Time Approver', 'employee',
					'custpage_5');*/


			// get all allocated resources
			var allocationSearch = nlapiSearchRecord('resourceallocation', null,
				[
					new nlobjSearchFilter('project', null, 'anyof', projectId),
					new nlobjSearchFilter('enddate', null, 'notbefore', 'today'),
					new nlobjSearchFilter('custentity_implementationteam', 'employee', 'is', 'F'),
					new nlobjSearchFilter('custentity_employee_inactive', 'employee', 'is', 'F')
				],
				[
					new nlobjSearchColumn('resource'),
					new nlobjSearchColumn('timeapprover', 'employee'),
					new nlobjSearchColumn('approver', 'employee')
				]);
			var allocationData = [];
			if (allocationSearch) {
				allocationSearch.forEach(function (allocation) {
					allocationData.push({
						employee: allocation.getValue('resource'),
						ta_old: allocation.getValue('timeapprover', 'employee'),
						ea_old: allocation.getValue('approver', 'employee'),
						_ta_new: '',
						_ea_new: ''
					});
				});
			}

			// add resource sublist
			// exp Manager section

			getForm.addTab('custpage_employee', 'Employees');
			getForm.addSubTab('custpage_expense_approver', 'Set Approver', 'custpage_employee');
			var subList = getForm.addSubList('custpage_resource', 'list',
				'Resources', 'custpage_expense_approver');
			getForm.addField('custpage_all_ex', 'select', 'New EA Approver',
				'employee', 'custpage_expense_approver');
			getForm.addField('custpage_all_ta', 'select', 'New TA Approver',
				'employee', 'custpage_expense_approver');
			/*getForm.addField('custpage_all_ex', 'select', 'New EA Approver',
					'employee');
			getForm.addField('custpage_all_ta', 'select', 'New TA Approver',
					'employee');
			*/
			subList.addButton('custpage_btn_expense', 'Update All EA', 'updateExpenseApprover');
			nlapiLogExecution('Debug', 'Update All EA button', '');
			//getForm.setScript('customscript1449');
			subList.addButton('custpage_btn_expense_2',
				'Update Selected EA', 'updateSelectedExpenseApprover');
			/*subList.addButton('custpage_btn_expense_2',
					'Update Selected EA', 'update');*/
			nlapiLogExecution('Debug', 'Update Selected EA button', '');
			getForm.setScript('customscript_sut_project_wise_ta_ea');
			/*subList.addButton('custpage_btn_expense_2',
					'Update Selected EA', 'clientFieldChanged();');
			nlapiLogExecution('Debug', 'Update Selected EA button', '');
			*/
			subList.addButton('custpage_btn_time', 'Update All TA', 'updateTimeApprover');
			nlapiLogExecution('Debug', 'Update all EA button', '');
			subList.addButton('custpage_btn_time_2', 'Update Selected TA', 'updationofSelectedTimeApprover');
			nlapiLogExecution('Debug', 'Update selectd TA button', '');

			subList.addField('employee', 'select', 'Employee', 'employee').setDisplayType('inline');
			subList.addField('ta_old', 'select', 'TA Old', 'employee').setDisplayType('inline');
			subList.addField('ea_old', 'select', 'EA Old', 'employee').setDisplayType('inline');
			subList.addField('_ta_new', 'select', 'TA New', 'employee');
			subList.addField('_ea_new', 'select', 'EA New', 'employee');
			subList.addField('select', 'checkbox', 'Select ');
			subList.setLineItemValues(allocationData);

			// add buttons and hidden fields
			getForm.addField('custpage_next_step', 'text', 'Next Step')
				.setDisplayType('hidden').setDefaultValue(
					'SubmitProjectDetails');

			getForm.addSubmitButton('Submit Changes');

			response.writePage(getForm);
		} else {
			renderProjectSelectionPage();
		}
	} catch (err) {
		nlapiLogExecution('ERROR', 'renderProjectDetailsPage', err);
		throw err;
	}
}
Copy code
function updateExpenseApprover() {//
	nlapiLogExecution('Debug', 'updateExpenseApprover fun called', '');
	var value = nlapiGetFieldValue('custpage_all_ex');

	if (isNotEmpty(value)) {
		updateAllInSection('custpage_resource', '_ea_new',
			value);
	} else {
		alert("Please select an employee");
	}
}
3 parts of the code since the code is way too big. Basic flow till user that is having issue is able to go is suitelet function -> renderProjectDetailsPage function -> and then the function "updateExpenseApprover" should trigger when the button with id "custpage_btn_expense' is clicked but its throwing updateExpenseApprover is undefined same with 3 other buttons.
I still want to highlight there is no access related thing in the code or in the deployment. And User is able to do other things with the suitelet, just those 4 buttons are not working for him. even though they are working for everyone else.
b
customscript_sut_project_wise_ta_ea
should be the id of the client script
what does that script look like
r
its this suitelet script only. Previous Developers didn't create any additional clinet script, they just set the current suitelet in setScript. Not a good practice but working.
b
consider what the docs tell you to do
dont expect to misuse things and have them work
r
I am getting your point and I know its not a good practice but its working fine for 5 years and even now no other user is having an issue, only 1 person is having it. That's what bothering me. I still feel the issue is not coming because of setScript could be wrong.
b
if you are absolutely sure, then the answer is to use the debugger to see if the script file is loading
r
sure about setting the suitelet itself in the setscript works, in multiple other scripts we currently have it is done like that. And the current suitelet for 12+ users its working fine. There is just one single person who is facing the issue. Will check with debugger, and thank you for the effort and time as always @battk
It was a network related issue @battk not sure what exactly not resolved, but either some browser config or some network/system config is blocking to load the resources. Error:403 is coming up for that particular user.
b
thats an authorization error
check the folders related to the file for restrictions
r
There is none.
b
what does the file record look like
r
Script is inside suitescript folder. Record which the suitelet is updating is employee and project. User has access to both of them, and it doesn't matter even if he didn't we would have got insufficient permission error right? Basically if we go to browser inspect and sources tab, the resources gets loaded, all the client scripts are loaded, for this particular employee these are not loading up. Nothing wrong from netsuite side.
b
there is an actual record in netsuite that represents the file
you need to inspect both that
and the folder that represents the suitescripts folder for restrictions
r
I have checked both there isn't any restriction. Plus if there was he would not be able land in the first suitelet page itself. And do other task in it. As I said before this is a suitelet and in suitelet using setscript we are setting the same suitelet to use the functions that are written in it for 4 functions, 1 for each button. Basically also using suitelet as a client script. Upon further investigation, I could find client script for this particular user are not loading at least when he is at this particular suitelet page. Some network/system/browser setting is blocking those resources/client script.. Still looking into what's the issue. Found it pretty unique, so just wanted to let you know.. Once we have the exact issue and solution will update further.
b
in normal circumstances, the actual suitelet file is never loaded by the client
so the permissions on it dont matter
you have decided to choose unusual circumstances, so now the permissions actually matter since client scripts are loaded in the client