preface

To learn more about NetSuite development, here is a brief summary of SuitScript

What is a SuitScript?

SuitScript is a common way to do NetSuite secondary development. SuitScript provides different script types for different application scenarios, and each script type has at least one entry point for script execution. Not only that, but SuitScript modularizes all of its apis so that we can load them on demand, consistent with the single responsibility principle.

Second, some important concepts

  • Entry point: The entry point through which a script gains control of a NetSuite application
  • Script type: Different script types correspond to different development scenarios
  • Modules: apis are assigned to different modules

Type of script

 1.1Bundle Installation Script A script executed during the installation of a Bundle. It is used primarily for data cleaning entry methods1.2Client Script is used to respond to user operations on the NS interface, such as input box value change, submission, and row addition1.3	Map/reduce Performs batch processing of arrays, saveSearch, files, or other batch data. It can be executed by multiple threads in a fixed period1.4Mass Update is used to uniformly process the data specified as search. It can be executed at fixed intervals or immediately. It can be executed in a single thread1.5Portlets are used to develop Dashboard controls1.6Restlet provides interface integration for system calls outside NS1.7Scheduled development of programs that are Scheduled to be executed, with ScheduledMap/Reduce and Mass Update have similar functions and are executed in a single thread1.8Suitelet is used to develop the NS interface1.9UserEvent is used to respond to database events such as data loading and data submission.1.10	Workflow Action
Copy the code

4. Common modules

Record: used for data creation, update, delete search: used for data queryCopy the code

SuiteScript templates

/ * * *@NApiVersion 2.0 // Suitescript version *@NScriptType ClientScript // Script type */
define([ 'N/error'].//define object, also called entry point function
    / /; [] is an array of modules specified in SuiteScript to load (that is, many modules can be loaded). 'N/error' is one of many modules, and different modules have different functions.
  function(error) {       // The callback function
	function pageInit(context) {     // Function defined in the callback function
		if(context.mode == 'create') {
			alert(1);
			jQuery('#inpt_entity2').attr("disabled".true);// You can use jquery directly in the interface
		}
		return true;
	}
	function saveRecord(context) {}
	function validateField(context) {}
	function fieldChanged(context) {}
	function postSourcing(context) {}
	function lineInit(context) {}
	function validateDelete(context) {}
	function validateInsert(context) {}
	function validateLine(context) {}
	function sublistChanged(context) {}

	return {      //return specifies the function logic corresponding to different entry points
		pageInit : pageInit,              For example, if the entry point is of type pageInit, then pageInit is executed;
		fieldChanged : fieldChanged,
		postSourcing : postSourcing,
		sublistChanged : sublistChanged,
		lineInit : lineInit,
		validateField : validateField,
		validateLine : validateLine,
		validateInsert : validateInsert,
		validateDelete : validateDelete,
		saveRecord : saveRecord
	};
});
Copy the code

reference

SuiteScript 2.0 API introduction – Bruce-Hu by Cnblogs.com