Form.addField(options)
Method Description |
Adds a field to a form. |
Returns |
serverWidget.Field object |
Supported Script Types |
Suitelets User event scripts -beforeLoad entry point For more information, see SuiteScript 2.x Script Types. |
Governance |
None |
Module |
|
Since |
2015.2 |
Parameters
The options parameter is a JavaScript object.
Parameter |
Type |
Required / Optional |
Description |
Since |
---|---|---|---|---|
|
string |
required |
The internal ID of the field. The internal ID must be in lowercase, contain no spaces, and include the prefix custpage if you are adding the field to an existing page. For example, if you add a field that appears as Purchase Details, the field internal ID should be something similar to |
2015.2 |
|
string |
required |
The label for this field. |
2015.2 |
|
string |
required |
The field type for the field. Use the serverWidget.FieldType enum to define the field type.
Important:
Long text fields created with SuiteScript have a character limit of 100,000. Long text fields created with Suitebuilder have a character limit of 1,000,000. |
2015.2 |
|
string |
optional |
The internalId or scriptId of the source list or record type for this field if it is a select (List/Record) or multi-select field. Source list is a category containing standard lists and custom lists. Record types include standard record types like employee, sales order, and transaction, as well as custom record types. Examples of IDs include: standard record (salesorder, customer, employee); custom record (customrecord_car_model); standard list: (employeetype, ordertype); custom list (customlist_color).
Important:
After you create a select or multi-select field that is sourced from a record or list, you cannot add additional values with Field.addSelectOption(options). The select values are determined by the source record or list.
Note:
For radio fields only, the source parameter must contain the internal ID for the field. For more information about working with radio buttons, see SuiteScript 1.0 Documentation. |
2015.2 |
|
string |
optional |
The internal ID of the tab or field group to add the field to. By default, the field is added to the main section of the form. |
2016.1 |
Syntax
The following code sample shows the syntax for this member. It is not a functional example. For a complete script example, see N/ui/serverWidget Module Script Samples.
//Add additional code
...
var form = serverWidget.createForm({
title : 'Simple Form'
});
var field = form.addField({
id : 'custpage_abc_text',
type : serverWidget.FieldType.TEXT,
label : 'Text'
});
...
//Add additional code