The N/ui/serverWidget module is used to programmatically build custom forms, sublists, tabs, and field groups for Suitelet pages. It is the foundation of all custom UI in NetSuite server-side scripts.
Building a Simple Form
/**
* @NApiVersion 2.1
* @NScriptType Suitelet
*/
define(["N/ui/serverWidget"], (serverWidget) => {
const onRequest = (context) => {
if (context.request.method === "GET") {
const form = serverWidget.createForm({ title: "My Custom Form" });
form.addField({ id: "custpage_name", label: "Full Name", type: serverWidget.FieldType.TEXT });
form.addField({ id: "custpage_email", label: "Email", type: serverWidget.FieldType.EMAIL });
form.addField({ id: "custpage_notes", label: "Notes", type: serverWidget.FieldType.TEXTAREA });
form.addSubmitButton({ label: "Save" });
context.response.writePage({ pageObject: form });
}
};
return { onRequest };
});
Common Field Types
| Field Type | Description |
|---|---|
FieldType.TEXT | Single-line text |
FieldType.TEXTAREA | Multi-line text |
FieldType.INTEGER | Whole number |
FieldType.FLOAT | Decimal number |
FieldType.CURRENCY | Currency amount |
FieldType.DATE | Date picker |
FieldType.CHECKBOX | Boolean checkbox |
FieldType.SELECT | Drop-down list |
FieldType.MULTISELECT | Multi-select list |
FieldType.INLINEHTML | Raw HTML content |