Just curious if other people get this. Trying to ...
# suitescript
j
Just curious if other people get this. Trying to create a Client Script. When I upload the Script File and try to create a Client Script record with it, I get this
Error SuiteScript 2.1 entry point scripts must implement one script type function.
. If I comment out the two lines starting with
md_ui
the error goes away, and lets me create the Client Script record. After that, I can uncomment those two lines, and my script executes as desired. Is NetSuite really not able to deal with something before the first “script type function”?
Copy code
/**
 * cl_product_ss2.1.js
 *
 * @NApiVersion 2.1
 * @NScriptType ClientScript
 *
 * Custom Form Script for Product form
 *
 * Last modified 2023-08-28 JB
 */

define(['/SuiteScripts/2.0/module/md_integrity_ss2.1', '/SuiteScripts/2.0/module/md_ui_ss2.1'], function(md_integrity, md_ui) {

	md_ui.hideChildRecordButtons('custrecord_defctrct_product');
	md_ui.hideChildRecordButtons('custrecord_defuw_product');

	function fieldChanged(context){ return true; } // placeholder

	function pageInit(context) { return true; } // placeholder

	function saveRecord(context) { return true; } // placeholder

	/* Return the names of the functions.  Note that these can be different from the
	 * actual names above, but for clarity let's keep them the same.
	 */
	return {

		fieldChanged: fieldChanged,
		pageInit: pageInit,
		saveRecord: saveRecord

	}

});
b
probably giving the wrong error message
but netsuite has to interpret the code you write to figure out the entry point functions used
and to do various validations
if your code throws an error during that process it will fail to upload
though as a client script, your code runs in a different environment than the server that does the interpreting
so its possible to write a script that fails validation but will work clientside
which means you can give a simplifed version to upload initially to create the script record and then add in the breaking stuff
typically a bad idea since it leave the code in an intermediate state where sometimes you can make changes to it and sometimes you cant
e
Yes I've experienced this and it will complain even for the simplest things like not being able to find the window object in a client script. Like you I comment the "offending" line(s) and create the script record and once the script record is created, I uncomment the offending lines and update the client script file. It didn't stumble upon those before but it has been doing that lately in the past month or so.
j
yeah, it’s not the END of the world but still annoying.
also won’t let me deploy it to a record type without commenting out the lines it doesn’t like
b
the easy solution is to add something like
Copy code
if (typeof document !== 'undefined') {
}
j
Copy code
/**
 * cl_product_ss2.1.js (TRY TO CHANGE THIS LINE TO THE BOTTOM)
 *
 * @NApiVersion 2.1
 * @NScriptType ClientScript
 *
 * Custom Form Script for Product form
 *
 * Last modified 2023-08-28 JB
 */
(THIS SPACE HERE HAS FIXED THINGS FOR ME BEFORE)
define(['/SuiteScripts/2.0/module/md_integrity_ss2.1', '/SuiteScripts/2.0/module/md_ui_ss2.1'], function(md_integrity, md_ui) {