The quick answer
Upload a Client Script that exports pageInit, create its script record, and save a deployment with your custom record type selected in Applies To. Keep a test deployment enabled for the script owner, then open a new editable form. Match the resulting defaults to the field IDs and list-option ID used in the code.
This example uses Dispatch Intake, an existing custom record type. Its new form gets Portland Hub for Warehouse Location, Taylor Morgan for Sales Rep and Northstar Parcel for Shipping Carrier Company. This illustrated walkthrough uses synthetic example data. Person and operating-company names are fictional. Use the record type, fields and option IDs from your account.
Before you start
You need access to the custom record type, SuiteScripts in the File Cabinet, and script/deployment records. The example uses Administrator. Available forms, menu links and permissions depend on the account.
Dispatch Intake and its three fields already exist. Warehouse Location and Sales Rep are Free-Form Text fields. Shipping Carrier Company is a List/Record field pointing to the custom list Dispatch Carriers, where Northstar Parcel is option internal ID 9. This walkthrough deploys the prepared script; it does not build those prerequisites or write the file during the recording.
Use a test deployment and an unsaved test form first. The function below has no create-only guard. It can replace values when an existing record opens for editing or copying. pageInit does not run on a view-only form, and these browser defaults do not enforce values for imports or other non-UI entry paths.
01 · Check the starting form
Open Customization > Lists, Records, & Fields > Record Types. Beside Dispatch Intake, choose New Record. Confirm that Warehouse Location, Sales Rep and Shipping Carrier Company are empty, then cancel the unsaved form.
02 · Upload the prepared file
Save the example code shown in the final section as dispatch_defaults.js before starting. Replace its field IDs and values with your account's equivalents.
Open Customization > Scripting > Scripts, then New or New Script, depending on the account. On Upload Script File, choose New beside Script File. Attach From is Computer. Choose the prepared file, confirm File Name and the SuiteScripts folder, and save it. The uploaded file is selected on Upload Script File.
03 · Create the Client script record
Choose Create Script Record. The file declares ClientScript and API version 2.0. Enter Dispatch Defaults CS and ID customscript_dispatch_defaults, then save. NetSuite may supply the ID prefix separately; check the resulting complete ID.
Verify that Owner is Alex Morgan, the employee testing this example. On the saved script's Scripts tab, Page Init Function is checked. The script record now exists, but it still needs a deployment to attach it to Dispatch Intake.
04 · Deploy to the custom record type
Choose Deploy Script. Set Applies To to Dispatch Intake and use ID customdeploy_dispatch_defaults. Keep Deployed checked and Status set to Testing. If Event Type is shown, leave it empty for this example. Confirm the complete saved deployment ID if the page supplies its prefix separately.
In Audience, select Alex Morgan under Employees and save. Alex is also the script owner. Testing limits execution to the script owner. Selecting another employee in Audience does not make that employee the owner or enable their Testing access. Audience controls the intended scope when the deployment is Released; this example remains in Testing.
05 · Verify the unsaved form
Return to Record Types and choose New Record for Dispatch Intake. Without entering values into the three fields, check Portland Hub, Taylor Morgan and Northstar Parcel. These are editable form values. Opening the form has not saved a record.
If the fields remain empty, check the file's exported entry point and field IDs, the selected record type, Deployed, status and script owner for Testing. For a Released deployment, also check its audience. Account-specific forms or other scripts can also affect the result. Cancel this unsaved test after checking.
06 · Check field and option IDs
Open the Dispatch Intake record type's Fields tab. The script targets custrecord_dispatch_warehouse, custrecord_dispatch_sales_rep and custrecord_dispatch_carrier. Field labels are not these identifiers.
Open Customization > Lists, Records, & Fields > Lists, then Dispatch Carriers. Northstar Parcel has internal ID 9. The two text assignments use strings; the List/Record assignment uses the option's numeric internal ID. If the column is absent, obtain the list entry's internal ID through an available permitted method; Show Internal IDs in preferences may make it visible.
07 · Compare the uploaded code
Open the saved script's file preview. Confirm the ClientScript annotation, exported pageInit, exact field IDs and numeric carrier value. The example file is:
/**
* @NApiVersion 2.0
* @NScriptType ClientScript
* @NModuleScope SameAccount
*/
define([], function () {
function pageInit(context) {
var rec = context.currentRecord;
rec.setValue({fieldId: 'custrecord_dispatch_warehouse', value: 'Portland Hub', ignoreFieldChange: true});
rec.setValue({fieldId: 'custrecord_dispatch_sales_rep', value: 'Taylor Morgan', ignoreFieldChange: true});
rec.setValue({fieldId: 'custrecord_dispatch_carrier', value: 9, ignoreFieldChange: true});
}
return {pageInit: pageInit};
});
Return to a new Dispatch Intake form and check all three defaults again. Leave the test unsaved. This verifies form defaulting, not record persistence. Before reusing the example for normal records, decide whether it should run only when context.mode is create.
Common questions
What is the difference between the script record and its deployment?
The script record identifies the uploaded file, API version and owner. The deployment selects the record type and execution scope. Saving Dispatch Defaults CS alone does not attach it to Dispatch Intake.
Why are the fields still empty after deployment?
Check that the file exports pageInit, the three field IDs exist, and the deployment is enabled for the correct custom record type. In Testing, verify that you are the script record owner. For Released, also check the audience. The selected form and other customizations can affect the result.
Is option internal ID 9 the same as the carrier field ID?
No. custrecord_dispatch_carrier identifies the field. Dispatch Carriers is the custom list supplying its options, and 9 identifies its Northstar Parcel entry. The call targets the field and assigns the entry's internal ID.
Does pageInit run on a view-only record?
No. Test an editable form. The relevant initialization modes are create, edit and copy; viewing an existing record is not the same test.
Are these defaults saved automatically?
No. setValue changes the browser's current form. The values remain unsaved until the record is saved. This walkthrough does not show a save, and it does not enforce defaults for imports or other non-UI entry paths.
Can this code replace values on edit or copy?
Yes. The supplied function calls setValue without checking the mode. When it executes on edit or copy, its assignments can replace existing values. A create-only guard is an additional change to consider; it is not implemented in this example.