To enhance the efficiency and accuracy of sales orders, we implemented a restriction that allows only service items to be selected within the sales order process in NetSuite. First, we created a service item entity by navigating to Lists > Accounting > Items > New, selecting Service Item for Sale, and configuring the necessary details. Next, we developed a client script to filter item selection to only service items. The script was deployed by uploading it via Customization > Scripting > Scripts > New, ensuring it was set to Client Script, and then configuring the deployment to target the Sales Order record type. This script automatically restricts item options to service items whenever a new sales order is created or edited. Finally, the implementation was tested by creating a new sales order and verifying that only service items were available for selection, thereby reducing errors and streamlining the sales process.
Client Script:
/**
* @NApiVersion 2.x
* @NScriptType ClientScript
*/
define([‘N/search’, ‘N/record’], function(search, record) {
function pageInit(context) {
if (context.mode !== ‘edit’ && context.mode !== ‘create’) {
return;
}
var currentRecord = context.currentRecord;
var sublistField = currentRecord.getSublistField({
sublistId: ‘item’,
fieldId: ‘item’,
line: 0
});
if (sublistField) {
sublistField.isDisabled = true;
var serviceItemSearch = search.create({
type: search.Type.ITEM,
filters: [
[‘type’, ‘anyof’, [‘Service’]]
],
columns: [
‘internalid’,
‘itemid’
]
});
serviceItemSearch.run().each(function(result) {
var itemId = result.getValue(‘internalid’);
var itemName = result.getValue(‘itemid’);
sublistField.insertSelectOption({
value: itemId,
text: itemName
});
return true;
});
sublistField.isDisabled = false;
}
}
return {
pageInit: pageInit
};
});