Share via


FormRun.dataSource Method

Retrieves a FormObjectSet object for a specified form data source.

Syntax

public FormObjectSet dataSource([anytype objectSet])

Run On

Client

Parameters

  • objectSet
    Type: anytype
    A specified form data source; optional.

Return Value

Type: FormObjectSet Class
A FormObjectSet object for a specified form data source.

Remarks

You can use an Integer data type for the objectSet parameter.

You can use the return value from the dataSource method to instantiate the FormDataSource class.

Examples

The following example shows a call to the dataSource method to specify the first data source that is added to the form. The Form.addDataSource method is used to add two data sources to the form.

static void createForm(Args _args) 
{ 
    Args args; 
    Form form; 
    FormRun formRun; 
    FormBuildDesign formBuildDesign; 
    FormBuildDataSource formBuildDataSource; 
    FormBuildDataSource formBuildDataSource2; 
    FormBuildGridControl formBuildGridControl; 
    FormDataSource formDataSource; 
    DictTable dictTable; 
    DictTable dictTable2; 
    int idx;  
    // Create the form header. 
    form = new Form(); 
 
    // Add data sources to the form. 
    dictTable = new DictTable(tablenum(CustTable)); 
    formBuildDataSource = form.addDataSource(dictTable.name()); 
    formBuildDataSource.table(dictTable.id()); 
    dictTable2 = new DictTable(78); 
    formBuildDataSource2 = form.addDataSource(dictTable2.name()); 
    formBuildDataSource2.table(dictTable2.id()); 
 
    // Create the form design. 
    formBuildDesign = form.addDesign("Design"); 
 
    // Add a grid control. 
    formBuildGridControl = 
 formBuildDesign.addControl(FormControlType::Grid, "Table Grid"); 
    formBuildGridControl.dataSource(dictTable.name()); 
 
    // Add a data field to the grid control. 
    formBuildGridControl.addDataField(formBuildDataSource.id(), 
    dictTable.fieldName2Id("AccountNum")); 
 
    args = new Args(); 
    args.object(form); 
 
    // Create the run-time form. 
    formRun = new FormRun(Args); 
    formRun.run(); 
    formRun.detach(); 
 
    // Return an object for the first data source, 
    // and then display a query form. 
    formdatasource = formRun.dataSource(1); 
    formdatasource.prompt(); 
}

See Also

Reference

FormRun Class