Script to auto-populate the Location based on Subsidiary

Client Script function postsourcing(context){ if(context.fieldId == ‘entity’){ var subsidiary =  record.getValue({ fieldId: ‘subsidiary’ }); switch(subsidiary){ case ‘2’: var location = ‘location ID 1’ break; case ‘4’: var location = ‘location ID 2’ break; case ‘3’: var location = ‘location ID 3’ break; case ‘7’: var location = ‘location ID 4’ } recordObj.setSublistValue({   fieldId: ‘location’, value:… Continue reading Script to auto-populate the Location based on Subsidiary

Restrict a User Role to Only Edit a Record via SuiteScript

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

Extract Search Results via SuiteScript with the Ordering Similar to User Interface

To extract the different Kit/Package Item records using Suite Script with the same order as the one in the User Interface when viewing the record. Define the filters. Define the internal id as one of the results columns. var search = search.create({ type: item, filters:, //define filters here columns: [{ name: internalid, sort: search.Sort.ASC }],… Continue reading Extract Search Results via SuiteScript with the Ordering Similar to User Interface

Search for the Shipping Cost in a Sales Order Using SuiteScript

The Field ID of Shipping Cost in a Sales Order record is “shippingcost”. However, when retrieving its value using SuiteScript, the Field ID that should be used is “shippingamount” instead. The field internal id “shippingamount” is listed under Search Columns. var lookupFields = search.lookupFields({‌ type:search.Type.SALES_ORDER, id: 12345, columns: [‘shippingamount’] })

Create a Customer record using SuiteScript 2.0

A new Customer Record needs to be created individually in NetSuite. A fast and easy way to do so is using the NetSuite Suite Script Debugger. It makes easier to troubleshoot and adapt later Suite Script developments on the account. Navigate to Customization > Scripting > Script Debugger Select SuiteScript 2.0 as the API Version Note: Make sure that the mandatory fields… Continue reading Create a Customer record using SuiteScript 2.0

Deploy a Script via SuiteScript API

NetSuite Suite Script APIs support the creation of different standard record types, allowing for a wider customization. Included in the supported record types is also the Script Deployment record. This allows for deployments to be created programmatically when using Suite Script. It can be helpful, for example, if one single script file needs to be… Continue reading Deploy a Script via SuiteScript API

CPE Dashboard using Vue.js

<!DOCTYPE html> <html lang=”en”> <head>     <meta charset=”UTF-8″>     <meta name=”viewport” content=”width=device-width, initial-scale=1.0″>     <title>Program Delivery Dashboard</title>     <script src=”https://cdn.jsdelivr.net/npm/vue@2″></script>     <style>         body {             margin: 0;             font-family: Arial, sans-serif;          … Continue reading CPE Dashboard using Vue.js

Setting the Create PO field to null via SuiteScript

function beforeSubmit(type){ var count = objRecord.selectLine({ sublistId: ‘item’, line: i }); for (i=1; i<= count; i++)    {         var currentContext = runtime.executionContext();         //setting of ‘createpo’ field only happens when the script is triggered via Web Services         //add other if conditions here, if needed… Continue reading Setting the Create PO field to null via SuiteScript

SuiteScript Error: “INVALID_FLD_VALUE : You have entered an Invalid Field Value” for Custom Field

The error “INVALID_FLD_VALUE: You have entered an Invalid Field Value” Invalid Value details which is returned if there is any instance of setting a field value that is different from the type of value the field is expecting. The specific field value error above is returned when a time value is set via script to… Continue reading SuiteScript Error: “INVALID_FLD_VALUE : You have entered an Invalid Field Value” for Custom Field