If we want to restrict the direct contact creation(Netsuite standard record), we use a user event script and write the script in the beforeLoad entry point. And which is deployed/applied to the contact record type.
/**
- @NApiVersion 2.1
- @NScriptType UserEventScript
/ define([‘N/record’], /*
* - @param{record} record
*
/ ( record) => { /*
* Defines the function definition that is executed before record is loaded.
* @param {Object} scriptContext
* @param {Record} scriptContext.newRecord – New record
* @param {string} scriptContext.type – Trigger type; use values from the context.UserEventType enum
* @param {Form} scriptContext.form – Current form
* @param {ServletRequest} scriptContext.request – HTTP request information sent from the browser for a client action only.
* @since 2015.2
*/
const main = {
beforeLoad: (scriptContext) => {
let type = scriptContext.type;
// if type === ‘create’ then restrict the contact creation
if (scriptContext.type === scriptContext.UserEventType.CREATE) {
throw ‘ Contact creation restricted. Please contact administrator. ‘;
}
}
}
return main; });