Script.GetDataTable(TableName)
.GetDataTable(TableName) returns the named table as an object. The data contained in the table can then be accessed and written to using scripting. Finding the TableName is a bit more difficult; however, there are a few tricks to finding the information.
- UDFs: All UDFs belong to the same table on every form: cD2
- Functional ID: If you right-click on a caption, the functional ID contains the table name within the FID.
- Example: Sales Order Header Order Type field
- Input_eTORD_to_ordtype
- The information contained between the first two underscores (_) is the table name for the field
- In this case: eTORD
- Example: Sales Order Header Order Type field
Note: While you can use Event.Form.GetDataTable([TableName]) to access the various tables on a given form, the preferred method is to use Script.GetDataTable(TableName)
Applies To
- Event.Form.Parent
- Event.Form
- Script Object
Properties and Methods
Properties
- .Columns
- .Count
- Methods
- .AddBooleanColumn(Name)
- .AddDateTimeColumn(Name)
- .AddDecimalColumn(Name)
- .AddIntegerColumn(Name)
- .AddRow([IDColumn])
- .AddStringColumn(Name)
- .GetMaximumDateTime(ColName)
- .GetMaximumDecimal(ColName)
- .GetMaximumInteger(ColName)
- .GetMinimumDateTime(ColName)
- .GetMinimumDecimal(ColName)
- .GetMinimumInteger(ColName)
- .GetRow(X)
- .RemoveRow(Row)
- .SetNextIDValue(IDColumn, Row)
Available
The .GetDataTable(TableName) method is available in:
- 15.03.016
- All newer builds
Type
DataTable
Syntax
Script.GetDataTable(TableName);
Parameters
|
Parameter |
Required |
Description |
|---|---|---|
|
TableName |
Yes |
The name of the table you want to access. Can be left blank if using Event.Form.GetDataTable([TableName]). If left blank, then the DEACOM will return the default table for the form. |
Example
//--add this script to an event on the NewOrd1 form layout
var loTable = Script.GetDataTable('eTORD');
Event.Form.ShowDataTable(loTable);
/* Expected Prompt response:
.ShowDataTable() will open the Show All Fields Form with all the fields and data rows in the specified table.
Getting the data table is typically the first step to working with this data in scripting.
*/