Sample code snippet. const beforeLoad = (scriptContext) => { var type = scriptContext.type; var userObj = runtime.getCurrentUser(); var ACCESS_ROLE = userObj.role; if (ACCESS_ROLE != 3 && type == ‘create’) { var… Continue reading Restrict a User Role to Only Edit a Record via SuiteScript
Tag: suitescript 2.0
How to convert base64 text to a PNG image file in NetSuite
Recently, the client requested a feature to send PNG image file content to Netsuite as base64 text so that it would be converted to an actual file and stored in the file cabinet. Here is a sample function I created to test the functionality: function createFileFromBase64(base64String){ try { var folderId = 47609; // Folder ID… Continue reading How to convert base64 text to a PNG image file in NetSuite
Suitescript to create a folder under a parent folder in File Cabinet
The requirement was to create child folders under a previously decided parent folder in the NetSuite file cabinet. We should reuse the existing folders if a folder with the requested name already exists and no duplicate folders should be created. These folders can be used to store attachments related to records. Refer to the following… Continue reading Suitescript to create a folder under a parent folder in File Cabinet
Set Text value for list/record fields along with values using submitFields
record.submitFields({ type: ‘customrecord_grw019_loanrepayrec’, id: idRepayRec, values: { custrecord_grw017_loanrepayrec_nmbr: betNo, … Continue reading Set Text value for list/record fields along with values using submitFields
How to resolve SuiteScript 2 Error “please configure inventory detail in line x of the item list”
Description: When we update the items in sales orders or similar records that have inventory items, we might face the above error. By using this solution, we can resolve it. Solution: Remove the inventorydetail value from the sublist record so the configured inventory value will be deleted. refer below code currentRecord is the record that… Continue reading How to resolve SuiteScript 2 Error “please configure inventory detail in line x of the item list”
Form.addSublist(options)
This is the method to add a sublist to the custom form. This needs a module called N/ui/serverWidget. This return a serverWidget.Sublist object. It is supported in suitelet script type and user event script types (beforeload). The syntax is as follows: var sublist = form.addSublist({ id: ‘custpage_id’, type: serverWidget.SublistType.INLINEEDITOR, label: ‘Inline editor Sublist’ }); In… Continue reading Form.addSublist(options)
N/email module in Suitescript
In this module in suitescript, the syntax is: In the syntax, for the recipients, we can give either the id of the recipient or the email address of the recipient. The author should be the id of the sender. When we give the email in recipient, the email will be sent to them. But when… Continue reading N/email module in Suitescript
Create a folder using Suitescript 2.0 in NetSuite
Run the snippet of code below in the Script Debugger for testing.