Tuesday, July 10, 2018

Application Object Classes

These classes hold functions that are activated whenever you use the AOT to
create your application. For example, the system uses the
FormDesign class
when you define the layout of your form in the Designs node in the
AOT. When
you click
New CheckBox in the AOT, the system activates the controlNamemethod with a CheckBox type control as parameter.
These classes also enable you to create and modify application objects.


Form Classes

The Form classes enable you to manipulate, create, modify, or run forms by
using X++ code. You can also modify forms during run time so, for example, one
or more controls are hidden on a form, depending on the user's selections in the
preceding form.
The
Form classes are all system classes and are prefixed with Form. For
example, FormRun, FormStringControl.
The most important classes are described in the following table:

System class name Description
Form This class contains property methods for the form
name and other form properties and methods that
enable addition of data sources and controls to the
form.
Use this class to create a form from your X++
code rather than by using the AOT.
FormRun This class contains methods for executing a form.
FormDesign This class contains property methods for the
properties on the Design node for a form and
methods for creating controls.
Used at form runtime.
FormBuildDesign This class contains property methods for the
properties on the Design node for a form and
methods for creating controls.
Use this class to create the graphical layout of a
form by using X++ code.
Used to design a form.
FormDataSource This class contains property methods for the
properties on a form data source and methods for
changing the behavior of a data source (such as
caching, validation, and so on) and notification
methods for events on records in forms.
Used at form run-time.

FormBuildDataSource This class contains property methods for the
properties on a form data source. Use this class to
manipulate the properties on a form data source
by using X++ code.
Used to design a form.
FormControl FormControl is the parent class for all the other
form control classes. Use methods on the class for
the relevant control type rather than this parent
class.
Used at form run
-time.
Form<control
name>Control
(e.g. FormStringControl,
FormTreeControl, etc)
These classes contain property methods for an
individual control type and methods to manipulate
that control type.
Used at form run
-time.
FormBuild<control
name>Control
(e.g.
FormBuildStringControl
,
FormBuildTreeControl,
and so on.)
These classes contain property methods for an
individual control type.
Used to design a form.

The following example demonstrates how to create and then run a form using
X++ code:


1. Create a
Form object.

2. Add a datasource to the form using
Form.addDataSource().

3. Add a design to the form using
Form.addDesign().

4. Add the caption "Customer information" to the design using
FormBuildDesign.caption().

5. Add a Tab to the design using
FormBuildDesign.addControl().

6. Add two Tab Pages to the Tab using

FormBuildTabControl.addControl().

7. Add the captions "Overview" and "General" to the Tab Pages using
FormBuildTabPageControl.caption().

8. Add a grid to the first Tab Page using
FormBuildTabPageControl.addControl().

9. Add two strings to the second Tab Page using
FormBuildTabPageControl.addControl().

10. Add data fields (for AccountNum, Phone, Name and Address) to the
grid using
FormBuildGridControl.addDataField(), referencing theFormBuildDataSource object.
 
11. Set data sources to the string controls usingFormBuildStringControl.dataSource() and .dataField(),
referencing the
FormBuildDataSource object.

12. Create a new
Args object.

13. Pass Form object into
Args.object().

14. Use
ClassFactory.formRunClass(args) to create a FormRun class.

15. Run and detach the
FormRun object.

16. The method should look as follows:



 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
static void createForm()
{
Args args;
Form form;
FormRun formRun;
FormBuildDesign fbDesign;
FormBuildDataSource fbDS;
FormBuildGridControl fbGrid;
FormBuildStringControl fbStr1;
FormBuildStringControl fbStr2;
FormBuildTabControl fbTab;
FormBuildTabPageControl fbTabPage1;
FormBuildTabPageControl fbTabPage2;
DictTable dictTable;
int idx, idx2, idx3;
FormControlType fctTabPage = FormControlType::TabPage;
FormControlType fctTab = FormControlType::Tab;
FormControlType fctGrid = FormControlType::Grid;
FormControlType fctString = FormControlType::String;
// Create the form header.
form = new Form();
// Add a data source to the form.
dictTable = new DictTable(tablenum(CustTable));
fbDS = form.addDataSource(dictTable.name());
fbDS.table(dictTable.id());
// Create the form design.
fbDesign = form.addDesign("Design");
fbDesign.caption("Customer information");
// Add tab
fbTab = fbDesign.addControl(fctTab, "Overview");
// Add tab pages
fbTabPage1 = fbTab.addControl(fctTabPage, "Overview");
fbTabPage1.caption("Overview");
fbTabPage2 = fbTab.addControl(fctTabPage,"General");
fbTabPage2.caption("General");
// Add grid onto tab 1 and data fields onto grid.
fbGrid = fbTabPage1.addControl(fctGrid,"Table Grid");
fbGrid.addDataField(fbDS.id(),
dictTable.fieldName2Id("AccountNum"));
fbGrid.addDataField(fbDS.id(),
dictTable.fieldName2Id("CustGroup"));
fbGrid.addDataField(fbDS.id(),
dictTable.fieldName2Id("Currency"));
// Add string fields to tab 2, and assign datasource
fbStr1 = fbTabPage2.addControl(fctString,"String 1");
fbStr1.dataSource(fbDS.id());
fbStr1.dataField(dictTable.fieldName2Id("AccountNum"));
fbStr2 = fbTabPage2.addControl(fctString,"String 2");
fbStr2.dataSource(fbDS.id());
fbStr2.dataField(dictTable.fieldName2Id("CustGroup"));
// Create the run-time form.
args = new Args();
args.object(form);
formRun = classfactory.formRunClass(args);
formRun.run();
formRun.detach();
}

Best Regards,
Hossein Karimi

No comments:

Post a Comment

Configure the Firewall on the Enterprise Portal Server

After you install Enterprise Portal, enable Web Server (HTTP) in Windows Firewall. If you do not enable the web server in Windows Firewall...