Introducting MorphX


234 69 3MB

English Pages 276

Report DMCA / Copyright

DOWNLOAD PDF FILE

Recommend Papers

Introducting MorphX

  • 0 0 0
  • Like this paper and download? You can publish your own PDF file online for free in a few minutes! Sign Up
File loading please wait...
Citation preview

Navision Axapta

Axapta Developer's Guide (Part 1)

 Columbus IT Partner Russia, ApS

Navision Axapta

Contents Introducing MorphX..................................................................................................................... 7 1. Getting Help............................................................................................................................. 8 Using the Developer's Guide Help ............................................................................ 8 Print a Help topic ....................................................................................................... 8 Use shortcut keys ...................................................................................................... 8 Modify the Help document....................................................................................... 12 2. Developing Axapta Applications......................................................................................... 14 2.1. The Seven Steps of Application Development .......................................................... 14 Conceptualization: understanding the problem....................................................... 14 Create Extended Data Types based on the primitive data types............................ 15 Create tables to hold your data ............................................................................... 15 Design classes for handling business procedures .................................................. 15 Create forms for interacting with the user ............................................................... 16 Create reports to extract information and present surveys ..................................... 16 Create menus and menu items for accessing the functionality in your application 16 3. Using MorphX ....................................................................................................................... 17 3.1. Working with the Application Object Tree.................................................................. 17 An overview of the commands in the AOT shortcut menu...................................... 18 Application Object Tree nodes: an overview........................................................... 19 Working with projects .............................................................................................. 21 Saving your work ..................................................................................................... 21 The MorphX property sheet..................................................................................... 21 MorphX concepts you need to know ....................................................................... 22 3.2. Application Object Layers .......................................................................................... 24 Using the top level version of an object at all times ................................................ 25 Layer benefits .......................................................................................................... 26 Additional patch layers ............................................................................................ 26 Viewing layers in the application during development ............................................ 27 Using the Layers command..................................................................................... 28 Setting the current layer .......................................................................................... 29 Exporting objects from a selected layer .................................................................. 29 Tips ................................................................................... 30 3.3. Working with projects................................................................................................. 31 Open a project ......................................................................................................... 31 Create a new project ............................................................................................... 32 Create a new ptoject using the project filter funtion ................................................ 33 Autogenerate a project group.................................................................................. 33 Project tips............................................................................................................... 34 3.4. Using the editor.......................................................................................................... 34 Editor color codes.................................................................................................... 35 Use editor shortcut keys.......................................................................................... 35 Editor lookup facilities.............................................................................................. 36 Printing your code ................................................................................................... 37 Editor scripts: What they are and how they work .................................................... 37 3.5. Using the Debugger ................................................................................................... 37 To activate the debugger automatically when code is compiled............................. 37 To set breakpoints ................................................................................................... 38 Use debugger shortcut keys.................................................................................... 38 Using debugger information .................................................................................... 39 3.6. Working with more languages ................................................................................... 40 Ladels: What they are and how they work .............................................................. 40 Creating a label ....................................................................................................... 41 The label dialog ....................................................................................................... 41 Line breaks in labels................................................................................................ 42 Creating a label file.................................................................................................. 42 3.7. Working in MorphX .................................................................................................... 43 System classes: What they are and how they work................................................ 43  Columbus IT Partner Russia, ApS

2

Navision Axapta Locking the datebase in a multiuser environment................................................... 44 Using the fundamental classes ............................................................................... 45 Using global variabies ............................................................................................. 46 WinAPI (Windows Application Programming Interface) .......................................... 48 3.8. Securing date............................................................................................................. 49 Feature keys: What they are and how they work .................................................... 50 Define and enable a feature key ............................................................................. 52 Disabling a datebase feature key............................................................................ 52 Creating a feature keys hierarchy ........................................................................... 53 Feature key organization......................................................................................... 53 3.9. Backup of Application Objects ................................................................................... 55 Using the application object export import facilities ................................................ 55 Export application objects ....................................................................................... 56 Import application objects........................................................................................ 56 A note about exporting tables and classes ............................................................. 57 3.10. Tips................................................................................................................ 57 Setting development options ................................................................................... 57 Easing your login procedure.................................................................................... 60 Using Windows Regional Settings .......................................................................... 62 How do I locate… .................................................................................................... 63 Add company logo to the Main menu...................................................................... 64 Executing commands on startup ............................................................................. 64 4. Working with MorphX Development Tools ........................................................................ 66 4.1. Using the Cross-Reference system ........................................................................... 67 Create a cross-reference system ............................................................................ 67 Using the cross-reference system........................................................................... 68 4.2. Generating an Application Hierachy Tree.................................................................. 70 Application Hierarchy Tree information ................................................................... 70 If information for a hierarchical view is not available............................................... 72 4.3. Using the MorphXplorer ............................................................................................. 72 Creating a tables relation diagram .......................................................................... 73 Include class and map information in a table relations diagram ............................. 74 Creating a classes diagram..................................................................................... 75 Including super and sub classes information in a class diagram ............................ 75 Opening, saving, and printing diagrams from the MorphXplorer ............................ 76 Arranging, zooming, and copying in the MorphXplorer ........................................... 76 Legend in the MorphXplorer.................................................................................... 77 4.4. Other Tools ................................................................................................................ 77 Using the application objects list ............................................................................. 77 4.5. Creating Wizards ....................................................................................................... 79 Create a wizard ....................................................................................................... 80 Guidelines for wizard development ......................................................................... 81 The wizard class...................................................................................................... 82 The wizard form....................................................................................................... 83 Wizard tips............................................................................................................... 83 4.6. Tips . ............................................................................................. 86 Searching on properties .......................................................................................... 86 5. Creating a Database ............................................................................................................. 88 5.1. Database Basics ........................................................................................................ 88 Databases and MorphX........................................................................................... 88 The MorphX Interface Layer.................................................................................... 88 5.2. Databases and Companies ....................................................................................... 89 Dividing a database into companies ....................................................................... 89 Working with companies ......................................................................................... 90 Creating table collections, virtual companies and companies ................................ 90 Who creates what.................................................................................................... 92 5.3. Extended Data Types ................................................................................................ 92 Basing one Extended Data Type on another .......................................................... 94 Defining Extended Data Types as arrays................................................................ 95 Creating Extended Data Types ............................................................................... 95 3

 Columbus IT Partner Russia, ApS

Navision Axapta Customizing Extended Data Types ......................................................................... 96 Description of properties for Extended Data Types ................................................ 97 Adding dimensions .................................................................................................. 99 Complete these steps to add a dimension: ..................................................................... 100 5.4. Table Basics ............................................................................................................ 103 Creating tables ...................................................................................................... 106 Using keys in tables .............................................................................................. 107 5.5. Relationships ........................................................................................................... 108 Creating a relationship .......................................................................................... 109 Creating a relationship on an Extended Data Type .............................................. 110 Creating a condition on a relationship on an Extended Data Type....................... 110 Creating a relationship on a table ......................................................................... 111 Creating a condition on a relationship on a table .................................................. 112 Adding conditions to your relationships................................................................. 114 Validation and integrity .......................................................................................... 115 Using delete actions .............................................................................................. 116 5.6. Using Code in Tables............................................................................................... 117 Sequence of execution of methods....................................................................... 123 Defining and modifying methods in your tables .................................................... 123 5.7. Indexes . ............................................................................... 124 Deciding what to index .......................................................................................... 125 Creating an index .................................................................................................. 126 Description of properties for indexes..................................................................... 126 5.8. Ways to customize................................................................................................... 127 Customizing fields in a table.................................................................................. 131 Modifying tables that contain data......................................................................... 134 Temporary tables .................................................................................................. 135 Using maps............................................................................................................ 135 Creating a map...................................................................................................... 136 5.9. Tips . ........................................................................................ 137 Using Index and Order By in select statements .................................................... 137 Caching lookups .................................................................................................... 138 Browsing data........................................................................................................ 141 6. Creating forms .................................................................................................................... 143 6.1. Form basics ............................................................................................................. 143 What is a form and what is it used for? ................................................................. 143 The basic steps in defining a form ........................................................................ 143 What are controls and how do their properties relate to properties in their underlying fields? .......................................................................................................... 145 Access keys on forms ........................................................................................... 149 Using the graphical forms editor............................................................................ 150 Automatic reports on data in forms ....................................................................... 150 Guidelines for form design .................................................................................... 151 6.2. Ways to Customize Your Form................................................................................ 152 Add a picture to a form .......................................................................................... 152 Add a control to a form .......................................................................................... 152 Create a form with tabs ......................................................................................... 153 Bind an unbound control to a field......................................................................... 153 Change the tab order on a form ............................................................................ 154 Delete a control on a form ..................................................................................... 154 Format groups on your form.................................................................................. 154 Group controls on your form.................................................................................. 154 Use image lists for Tree controls and ListView controls ....................................... 154 Modify the shortcut menu on controls ................................................................... 156 Description of properties for controls .................................................................... 157 Description of properties for a form data source ................................................... 177 Description of properties for form design .............................................................. 179 Joining data sources on forms .............................................................................. 180 6.3. Designing Forms...................................................................................................... 183 Determining the opening view of a form................................................................ 183 Specify whether a form opens for modification and data entry ............................. 184  Columbus IT Partner Russia, ApS

4

Navision Axapta

6.4. 6.5.

6.6.

6.7. 6.8.

6.9.

Implicit forms variable declarations ....................................................................... 184 Validate or restrict data in forms............................................................................ 184 Order of evaluation for controls and fields ............................................................ 185 Auto-arrange principles in forms ........................................................................... 185 Sizeable forms....................................................................................................... 188 Toggling between different views on data............................................................. 188 Display a message box ......................................................................................... 189 Using display and edit method modifiers .............................................................. 190 The standard lookup form: what it consists of....................................................... 192 The lookup facility: creating you own lookup forms .............................................. 193 Creating a run-time lookup form............................................................................ 196 Tips ................................................................................... 198 Using ActiveX controls ............................................................................................. 199 Adding an ActiveX control to a form...................................................................... 199 Forms System Classes ............................................................................................ 201 Form control system classes................................................................................. 202 Constructing a form from your X++ code .............................................................. 202 Add a picture to a form using a system class........................................................ 203 Accessing the active query on a form ................................................................... 204 Events on forms ....................................................................................................... 206 Methods on a form ................................................................................................ 208 Methods on a form data source............................................................................. 211 Methods on form controls...................................................................................... 213 Forms: Examples ..................................................................................................... 225 An example: a typical form from the standard application .................................... 225 An additional benefit of creating relations................................................................ 230 An example of a Progress control ......................................................................... 231 An example of a Window control........................................................................... 233 Optimizing and Troubleshooting Forms................................................................... 234 Troubleshoot forms ............................................................................................... 234 Optimize form performance................................................................................... 234

7. Creating Queries................................................................................................................. 235 7.1. Quiries basics .......................................................................................................... 235 The standard QueryForm ...................................................................................... 235 Organization of queries ......................................................................................... 237 7.2. Creating a query ...................................................................................................... 238 Creating relations between embedded data sources............................................ 239 Setting properties and default options................................................................... 239 Using multiple tables in a query ............................................................................ 241 Sequencing of retrieved records ........................................................................... 242 7.3. Using queries from other application objects........................................................... 243 Using Run classes for Query objects .................................................................... 243 Using Build classes for Query objects................................................................... 244 Queries in forms and reports................................................................................. 246 7.4. Queries and methods............................................................................................... 246 8. Creating Reports................................................................................................................. 248 8.1. Reports basics ......................................................................................................... 248 Report components ............................................................................................... 248 Data source and visual layout ............................................................................... 249 8.2. Creating a report ...................................................................................................... 250 Creating a report by using a wizard ...................................................................... 250 Using report templates .......................................................................................... 251 Report sections ..................................................................................................... 252 Creating a new report template ............................................................................. 253 Creating a report based on a design specification ................................................ 254 Creating a report with a custom design................................................................. 256 Creating a report with multiple designs ................................................................. 256 Using controls to display information from the database ...................................... 257 Example showing how to use a display method ................................................... 257 Description of properties for the data source query .............................................. 258 5

 Columbus IT Partner Russia, ApS

Navision Axapta Defining report orientation ..................................................................................... 258 8.3. Printing Reports ....................................................................................................... 259 Printing reports executed on the server ................................................................ 259 Choosing alternative report medium ..................................................................... 259 Disable printer selection ........................................................................................ 260 Fit to page.............................................................................................................. 262 8.4. Reports and methods............................................................................................... 262 Methods on a report .............................................................................................. 263 Overview of methods on a report .......................................................................... 263 The Fetch and Send methods ............................................................................... 265 Modifying the Fetch method on a report ............................................................... 265 Understanding the Send method on a report ........................................................ 266 Methods on the report design................................................................................ 266 Events on reports .................................................................................................. 266 Events caused by the Fetch method..................................................................... 267 8.5. Tips . ....................................................................................... 268 Overview of components in a report design.......................................................... 268 Printing headers for reports with many columns ................................................... 268 Sequencing of sections when printing a report ..................................................... 268 Setting font and font size....................................................................................... 269 Positioning sections relative paper edges............................................................. 269 Column headings and word wrap.......................................................................... 269 Missing bitmaps..................................................................................................... 270 9. Creating Menus................................................................................................................... 271 Creating a menu.................................................................................................... 271 Description of properties for menus ...................................................................... 271 Menu items: What they are and how they work .................................................... 272 Creating a menu item ............................................................................................ 272 Methods on a menu item....................................................................................... 273 Description of properties for menu items .............................................................. 273 Activating a menu item from your X++ code ......................................................... 274 Activating a class from a menu item ..................................................................... 276

 Columbus IT Partner Russia, ApS

6

Navision Axapta

Introducing MorphX The development environment in Axapta is called MorphX. It is referred to as an Integrated Development Environment, or IDE, because it integrates many different functions such as designing, editing, compiling, and debugging within a common environment. In most traditional development tools, each of these functions would operate as a separate program, each with its own interface. In the Application Object Tree the developer can create new application objects by using drag-and-drop, and setting properties. To make the developer's job easier and faster, the system has auto settings for all application object properties. The concept of inheritance is central to the system. Inheritance means that what is defined at lower levels in the system is automatically inherited by higher levels. One illustration of the concept of inheritance is the way a developer may modify and augment the system functionality by writing his own methods. An Axapta application is flexible and easily modifiable on many levels. Typically you need to modify only a single parameter for the entire system inherit your change. If, for example, you change the length of a database field from ten characters to twenty, this is automatically reflected on all forms in the application that display this field. Axapta is not tied to a specific database platform but has been designed to be used on top of a relational database such as Microsoft SQL server. X++ uses object-oriented programming principles such as encapsulation, inheritance, classes, objects, methods, and properties. The language has Java-like syntax, and incorporates SQL data manipulation statements.

7

 Columbus IT Partner Russia, ApS

Navision Axapta

1. Getting Help Using the Developer's Guide Help The Developer's Guide describes central concepts in MorphX and provides in-depth task oriented help to guide you through the development process. The book Using MorphX is a good place to begin if you want to learn about general system concepts and efficient ways to work in the system. When you are ready to begin developing your integrated enterprise solution or to customize the standard application, Developing Axapta Applications will guide you through the development process step by step. The Creating... books provide conceptual as well as task oriented help on designing Axapta application objects: tables, forms, queries, reports and menus. Securing a Database deals with all aspects of security in Axapta, from disabling features in the system to setting up users and user groups and monitoring database changes. Axapta includes a number of tutorials to demonstrate various form features. The Tutorials book holds brief desriptions of these tutorials. Axapta Language Reference is a reference guide to X++, the Axapta programming language. Axapta Application Development Standards holds information about the development standards that form the basis of the application. Design Patterns in Axapta Applications holds guideline for good programming practice in Axapta. The Axapta COM Connector book includes a basics book with examples and a reference guide.



In the development environment, reference help information is available on for example functions and classes. 1. Expand the System Documentation or the Application Developer Documentation node. 2. Locate the item you want help on and press F1. Alternatively, press F1 and click the Search button on the toolbar.

Print a Help topic 1. In the Help topic window, click the Printer icon on the toolbar. 2. Choose between printing the selected topic, or printing all topics in the selected heading. 3. Click OK.



The version and setup of Microsoft Internet Explorer determines the print functionality on your system

Use shortcut keys You can use shortcut keys (also called accelerator keys) for quick access to frequently used commands or operations. The topics below describe shortcut keys generally available in Axapta and those specific to MorphX.



Click Shortcut keys on Axapta's Help menu for a complete list of system shortcut keys.

 Columbus IT Partner Russia, ApS

8

Navision Axapta

What do you want to do? Use global Axapta shortcut keys Printing and saving

Press

To save an application object

CTRL+S

To print an application object

CTRL+P

Cut, copy and paste

Press

To cut an application object

CTRL+X (SHIFT+DEL)

To copy an application object

CTRL+C (CRTL+INS)

To paste an application object

CTRL+V (SHIFT+INS)

Opening...

Press

To open the Application Object Tree

CTRL+D

Getting Help

Press

To get Help on an application object

F1

To display What's this? Help on an application object

SHIFT+F1

Getting Help

Press

To get Help on an application object

F1

Use shortcut keys in forms to locate records Filter functions

Press

To set up a filter

CTRL+F3

To clear a filter

CTRL+SHIFT+F3

Locating records

Press

To create a new record

CTRL+N

To find the first record

CTRL+HOME

To find the last record

CTRL+END

Deleting records To delete a record

ALT+F9

Use shortcut keys to navigate in forms

9

 Columbus IT Partner Russia, ApS

Navision Axapta Field navigation

Press

To go to first field

CTRL-SHIFT-HOME

To go to last field

CTRL-SHIFT-END

To go to previous field

SHIFT-TAB

To go to previous tab

CTRL-SHIFT-TAB

To go to next tab

TAB

To go to previous group

CTRL-SHIFT-PAGE UP

To go to next group

CTRL-SHIFT-PAGE DOWN

Use shortcut keys in the Application Object Tree When you want ...

Press

To open an application object

CTRL+O

To compile an application object

F7

To go to the previous node

UP

To go to the next node

DOWN

To move the node up

ALT+UP

To move the node down

ALT+DOWN

To expand the current node

RIGHT

To collapse the current node

LEFT

To expand the current node as much as possible

*

To collapse the current node as much as possible

-

Use shortcut keys in the editor To make it easier and faster to use the editor, use these shortcut keys: When you want to...

Press

Indent selection

TAB

Extend selection/remove indent

SHIFT+TAB

Open Help on a class

F1

Delete the previous word

CTRL+BACKSPACE

Open the Find/Replace dialog

CTRL+F

Find the next occurrence

F3

Compile

F7

Compile and close a method

F8

Set and delete a breakpoint

F9

Replace

CTRL+R

Jump to a method

CTRL+SHIFT+SPACEBAR

Mark a column

ALT+O

 Columbus IT Partner Russia, ApS

10

Navision Axapta To undo and redo

Press

Undo

CTRL+Z (latest ten actions)

Redo

CTRL+Y (latest ten actions)

To go to...

Press

The next method

CRTL+TAB

The previous method

CTRL+SHIFT+TAB

To look up...

Press

A label

CTRL+ALT+SPACEBAR

A Definition

CTRL+SHIFT+SPACEBAR

Properties and methods

CTRL+SPACEBAR

To list...

Press

Tables

F2

Classes

F12

Types

F4

Enums

F11

Reserved words

SHIFT+F2

Built-in functions

SHIFT+F4



You can also use the toolbar buttons in the editor to enable the facilities listed above and to save you code.

Use shortcut keys in the debugger To make it easier and faster to use the system’s debugger, use these shortcut keys: When you want to...

Press

Run the debugger

F5

Set or delete a breakpoint

F9

Show breakpoint table

SHIFT+F9

Step into

F8

Step over

SHIFT+F8

Step return

CTRL+F8

Open or close the variables window

ALT+2

Open or close call stack window

ALT+3

Open or close system variable window

ALT+4

Switch line numbers on/off

F4

11

 Columbus IT Partner Russia, ApS

Navision Axapta



You can also use the toolbar buttons in the debugger to enable the facilities listed above. The keys F5, F9 and SHIFT+F9 can also be used in the editor.

Modify the Help document This Help document was created using RoboHELP® for Microsoft HTML Help version 9 from eHelp Corporation. If you want to add or delete text from the Help document you need to acquire RoboHELP. You also need the HTML source files for the compressed Help file, Help project files (.mpj, .hhc, and .hhk), and style sheet file (.css). If you want to modify only the Contents tab (for example to remove one or more topics), you need the .hhc file.



Always keep a backup before making any modifications to files supplied with the Axapta system

To modify a Help topic 1. Create a directory, and a number of subdirectories, on your hard disk where you can place the project files and the document source files, for example HelpDir. The topics for each book in the Help file are located in a separate directory. The directory name is a three or four letter abbreviation of the title of the book, for exampe CRRP for "Creating Reports", CRDB for "Creating a Database". Within each directory, the file names are prefaced the directory "CRRP_Reports_basics.htm" and "CRDB_Databases_and_MorphX.htm".

name,

for

example

Underscores are used because the Microsoft HTML Help compiler currently cannot handle spaces. 2. Copy the .htm files to subdirectories and the project files and the style sheet to HelpDir.



The project files and the .htm files are not normally shipped with the system.

3. Activate RoboHELP and select the project file called axdvgus.mpj. 4. From the Project tab, open the file you want to modify. 5. Modify the text as needed and re-compile the Help project. To use the revised Help document, copy the .chm file to the directory where you have installed your Axapta system.

To modify the Contents tab The table of contents for an HTML Help file is saved in a file with extension .hhc. The .hhc file is a text file that you can modify in any text editor. This approach will probably be the easiest if you merely want to delete a single entry in the Contents tab or modify a title.



Removing an entry from the Contents tab does not restrict the user's access to the information in the topic through the Index Tab in the Help project.

In RoboHELP there is a graphical tool dedicated to manipulate the .hhc file. You should use this tool if you want to make extensive modifications. Also, whenever you remove an entry from the contents, you should also delete the corresponding topic to prevent the user from getting access to information, you find unnecessary. When you have deleted or edited a topic as described in steps 1 through 5 in How to modify a Help topic you must 1. Activate the TOC Composer in RohoHELP  Columbus IT Partner Russia, ApS

12

Navision Axapta 2. Delete or modify a Book or Page as needed 3. Save the revised .hhc file and exit the Contents Tab Composer 4. Recompile the Help project. To use the revised Help document and contents file, copy the .chm file to the directory where you have installed your Axapta system.

13

 Columbus IT Partner Russia, ApS

Navision Axapta

2. Developing Axapta Applications 2.1. The Seven Steps of Application Development MorphX has been designed to make it easy to develop Accounting and Business Management Systems and Enterprise Resource Planning applications. When you create an application in the IDE, the Application objects will be generated automatically. Normally about 80 % of the Application objects you create will not require any modifications before they can be used. The remaining 20% of the Application objects will require some modifications to be made by the application programmer. MorphX contains code, form, and report editors, and so on to help you do this. One of the basic concepts when developing Axapta applications is reuse. Depending on whether your job is to make a new application from scratch or if your are going to modify or extend an existing application, it is very often possible to reuse functionality. If your job is to add new functionality to an existing application, then make sure that you know the individual parts of the existing application. If you do not know and understand the existing application, you may end up having created functionality that was not really necessary, because it already existed in the application. When designing an Axapta application you have to complete the following seven steps: 1. Conceptualization: understand the problem. 2. Create Extended Data Types based on the primitive data types. 3. Create tables to hold your data. 4. Create classes for handling business procedures. 5. Create forms for interacting with the user. 6. Create reports to extract information and present surveys. 7. Create menus and menu items for accessing the functionality in your application. This of course is an iterative process. When you have been working with for example step four for some time you will discover that you will have to redesign some of the things you made at step three and so on. You will always have to perform a parallel activity besides the ones mentioned above: testing your application. The scope of this text is not to teach you a specific technique for developing or testing software. Refer to one of the numerous textbooks available describing OOA, OOD, prototyping, and testing techniques.

Conceptualization: understanding the problem The first major step in the development process is realizing what the problem you want to solve is really about. These first thoughts give you valuable information about the purpose of the application. Another valuable source of information is the end users that are going to use the application. It is always a good idea to involve the end users at an early stage of the development process to make sure that your application solves the correct problem. By identifying how the application is going to be used and which routines the users will perform with the system you get a good idea of the data your application is going to handle. This makes it possible for you to come up with a set of Extended Data Types that can be used in your tables. Designing the tables will often be the most difficult part of the entire application development process. Getting your table design right is crucial as the rest of the application is built on top of the tables. In the conceptualization process it is also important that you identify the forms and reports that are needed. This is the only way you can design the underlying system to provide the information necessary in them. The most important results of this step is a clear picture of... • the problem the system is going to solve • the functionality of the system, that is, how will the application solve the problem  Columbus IT Partner Russia, ApS

14

Navision Axapta • who is going to use the system Other results of this step are first ideas of... • which Extended Data Types are needed • which tables are necessary (and relations between them) • which forms and reports the users need • the structure of the menus that gives access to the entire application When you have completed this step, test your results with the users/customers. Create a requirements specification together with your customer. The requirements specification can be made as a description of criteria which must be fulfilled.

Create Extended Data Types based on the primitive data types Extended Data Types are data types defined by the application programmer. An Extended Data Type is based on one of the primitive data types (or another Extended Data Type), but one or more properties have been modified to reflect a real world domain more accurately. Typically your analysis will identify a number of common types of data which occurs throughout the application. Assume for the moment that you have some items that you want to register in your application and that each item has a unique ID number. Instead of defining this unique ID number as a String with length 14 each time you need an unique ID number, MorphX allows you to define an Extended Data Type such as UniqueIDNo. Once this Extended Data Type has been defined, it is globally available in you application. Do not use Extended Data Types unless you are absolutely sure that the types of the data in the fields are identical. Using Extended Data Types in the wrong places will create unnecessary dependencies between otherwise unrelated modules in your application.

Create tables to hold your data Your tables and the relations between them make up the foundation of your application. A bad table design affects the whole application. This is why it is important to analyze your data and break it into tables before you create any other application objects Defining relations between your tables are closely related to defining Extended Data Types (the previous step). As in other systems based on relational databases it is possible to define relations between tables in MorphX. But in MorphX this concept is taken a step further. When you define your Extended Data Types you are allowed to define relations between the tables. You should make sure that your tables adhere to the first three normal forms. This brings many benefits, such as an increase in consistency and maintainability, a reduction in data redundancy and better search performance from smaller tables (with narrower rows). If you are not familiar with the relational model and the normal forms, you should refer to The Relational Model for Database Management Systems (1990) by E. F. Codd. When designing the logic of your application you should be aware of that MorphX allows you to modify the standard behavior of your tables by adding code to methods. This can be used to enforce integrity rules and define logic for your tables. The results of this step should be tested with... • your conceptual model • the customer (use the requirements specification) • Normalization rules 1, 2, and 3.

Design classes for handling business procedures Classes in MorphX allow you to reuse common functionality. Once you have defined a set of classes, they can be used from all other application objects in your application. Classes are not very useful on their own, but are intended to be used to solve tasks for other application objects, such as forms and reports. 15

 Columbus IT Partner Russia, ApS

Navision Axapta You might be tempted to start with coding as the first step to see how it works. This approach is not ideal in an Axapta application because code only runs in the context of an application object and an associated event. The results of this step should be tested with... • your conceptual model

Create forms for interacting with the user Axapta forms are not just screens for entering and editing data. To the users of your application the forms are the application, as it makes up most of the application’s user interface. Forms are the most important way for your users to interact with your application. By interacting with forms the users control the flow of your application. Start by creating a form that is used to enter data in your application. Add a few sample records of sample data to your tables. This makes it easier to see whether your forms (and reports) display the data you want. For each form, determine what data you want on it, and then create a data source that contains the data. This is also a test of your tables because you will be able to see if you can get the data you want from the tables. Normally the forms you create in MorphX are created directly in the Application object Tree. Having defined the form here, its visual layout is automatically generated by MorphX based on the information in your Extended Data Types and your tables. In most common situations the system-generated layout is ready to use, but depending on your special requirements you might want to modify the layout. The results from this step should be tested with... • your conceptual model • your customer

Create reports to extract information and present surveys Reports are used to get printed overview of information extracted from your application’s data. Typically you produce phone lists, sales summaries, or mailing labels using reports. Just like any other application object, reports are also created using the application object tree. The Axapta Report Editor automatically generates the report based on the design you define in the Application Object Tree.

Create menus and menu items for accessing the functionality in your application Creating menus and menu items is the final step before your application development process is finished. The end users access the functionality in your application through menus. Menus in MorphX are very flexible compared to other systems. An Axapta application normally has several menus that are customized specifically to certain uses of the systems. Furthermore MorphX allows the end users to make their own modifications and create their own special menus. Your Application objects are not accessed directly from the menus. Instead they are accessed by menu items. The Menu items serve as a layer between the end users and the application objects. The menu items are also used to limit access to the application, based on the privileges defined for the user. The results from this step should be tested with... • your customer • the conceptual model This completed the seven steps involved in developing an Axapta application. If you have followed the previous steps it is now time to check that the application you have made lives up to the criteria you and your customer have put up in the requirements specification.  Columbus IT Partner Russia, ApS

16

Navision Axapta

3. Using MorphX 3.1. Working with the Application Object Tree To open the Axapta Application Object Tree point to Open, and then click Application Object Tree on the File menu.

Pic. 3-1 The Application Object Tree holds all objects in your application along with tools to develop your own application, or to modify the standard modules in the Axapta application.

The structure of the tree resembles what you see in Microsoft Explorer, or the Windows Registry Editor. The tree is a hierarchy with a number of main nodes that you can click to branch to individual levels of nesting. From the main nodes, expand the tree to a number of levels. The small icon with a plus indicates that another expansion level is available. The small empty box icon indicates that the node is currently empty of contents but that you can create some contents. The nodes share two features: • A shortcut menu opened by right-clicking the node. The menu will look different depending on the kind of node; however, you will always find the Properties command (see next item). • A set of properties you can view in the node property sheet. To see the properties of the current node, right-click the node to open the shortcut menu, and click the Properties command, or click the properties icon in the toolbar.

The New command To create a new class, a new table in the database, a new form or a new report, right-click the relevant node to open the shortcut menu, and then click the New command. The New command will always create a new object of the type that can be inserted in the current node. 17

 Columbus IT Partner Russia, ApS

Navision Axapta For example a form consists of three types of objects – methods, data source, and graphical layout. So if you choose New on the Forms, a new form object with three subnodes is created. When it is possible to insert more than one object, the New command opens a submenu.

An overview of the commands in the AOT shortcut menu The available commands in shortcut menu depend on the type of node you open it on: Command

Use it to...

Add-Ins

open a submenu holding various MorphX tools, for example the crossreference system and a compare feature. Tip You can add you own commands to the submenu.

Compile

compile a method or a subtree. When you exit the editor without compiling (or saving) the system will automatically do so for you.

Copy

create a copy of the current object.

Cut

delete the current object while keeping a copy in the buffer.

Delete

delete the current object.

Duplicate

create a copy of the current object.

Edit

edit the X++ code or the graphical design of the current object.

Export

extract information from the system to a text file.

Find...

locate an object in the Application Object Tree. The dialog is virtually identical to the Find Files or Folders... dialog in Windows Explorer. Tip Use shortcut key CTRL+F.

Generate Design

have the system generate a report design based on the query structure.

Generate Specs From Query

have the system generate a design structure similar to the data source structure in the query.

Layers

view object in all layers. Note You always save, modify and delete in the current layer.

Lock

temporarily lock the current node for modifications from other users. This command is useful only in installations with multiple clients with access to the same data.

New

create an object that can be inserted in the current node.

New Programmable Section

have the system generate a section in your report that you must activate from your X++ code.

Open

activate the current object.

Open New Window

create a new window with the current object and its sub-nodes. The current object becomes the root of the new tree structure.

Override Method

choose a method to override. When you create a new an application object of type class, table, or form, a number of methods are created by the system. These methods call super() and thus execute the system's implementation of the method. You can add you own code to the methods thereby overriding the system's standard

 Columbus IT Partner Russia, ApS

18

Navision Axapta behavior. Use Override Method to add your own X++ code to one of these methods. For classes, the superclass' methods that can be overridden are also shown. Page Formatting

set up your report page size, paper source, orientation, and so on.

Paste

insert the object you have previously cut or copied.

Print...

print the current object.

Printer Setup

set up your report printer.

Properties

open the properties window with properties for the current object.

Refresh

update the list of application objects. To update the contents of the application objects, use the Restore command.

Remove

remove the current object from its present context. This command is useful, for example, when you want to remove an application object from a project but not from the Application Object Tree.

Rename

give the current object a new name. Tip You can also rename an object through its property sheet, or by clicking it twice.

Restore

re-read the current object from disk and discard the changes made since the last save. Note If you have set the Auto-Save option, the object restored from disk may be the one save by the system.

Save

commit the current object to your database.

Synchronize

synchronize the database with the SQL database. Whenever global changes to the data dictionary occur, you have to synchronize the SQL database as well. Global changes are changes that are not specific for a given table, such as the Extended Data Types, or Feature Keys. Since such a synchronization may take a while on large amounts of data, it is not done automatically, when a single change is made and saved (contrary to altering the properties on a given table, or index, which does cause an automatic SQL synchronization when the changes are saved). Note Whenever the system requires synchronization, the color of the Data Dictionary icon changes from yellow to red. Tip It is recommended to perform the synchronization when no other users are using Axapta.

Unlock

unlock the node you have previously locked for modifications from other users.

Application Object Tree nodes: an overview Node

Description

Data Dictionary

Use the Data Dictionary node to set up the data types and tables that make up your database. To define a database: •

19

Define the data types you plan to use in your set of tables  Columbus IT Partner Russia, ApS

Navision Axapta •

Set up each table in your database with fields, indexes and object methods.

Macros

A macro is a code or text substitution that cannot run independently, but can be used anywhere you can write code in the system, for example in jobs, classes and forms. The Macros node holds the macros used by the standard application. Besides viewing the existing code you can add your own macros.

Classes

Each class in the Classes node holds a class declaration with the class variables and a number of class methods with the code that operates on these variables. The classes are global and can be used anywhere. Most of these classes are part of the standard application. A different icon represents the classes that are an integral part of the development environment.

Forms

Using the Forms node, design the dialogs that are the user’s interface to the database. To create a form: •

Attach objects from the database using the Data Sources node



Define X++ functions to manipulate the form



Define the graphical layout of the form.

Web Forms

Using the Web Forms node, design the dialogs that are the user’s Web interface to the database.

Reports

A report is an effective way to present your data in a printed format. In the Reports node you design the ways you would like to display information. To create a report:

Queries



Use the Data Source node to attach a query



Define X++ functions to manipulate the report



Define the layout of the report.

Queries are used as the source of records for forms and reports. Use the Queries node to: •

Define which database tables you want to see data from



Define X++ functions to manipulate the data.

Jobs

The Jobs node typically holds small X++ programs that are often executed as batch jobs.

Menus

In the Menus node you design the menus you want the end user to see.

Menu Items

The Menu Items node holds the complete list of the functions that can be presented in a menu. When designing a user menu in the Menus node, you choose from this collection.

System Documentation

The System Documentation node contains reference documentation for the development environment.

Application Developer Documentation

The Application Developer Documentation node contains reference documentation for application tables and classes.

Application Documentation

The Application Documentation node contains reference documentation for the Axapta application. Documentation is also available on the individual forms in the application.

 Columbus IT Partner Russia, ApS

20

Navision Axapta

Working with projects A project is a subset of the Object Tree that allows you to group the components you are currently working on. A project is either private or shared. A private project is only available to the user who created it. In contrast, a shared project is available to all users, and can be used as a tool for workgroups to manage their work. Because a project is a subset of the complete tree, everything you create or modify in your project also automatically exists in the tree. Besides providing an overview of the process you are currently working on, using projects offer additional advantages. • When a node is edited in the project, the modifications are also automatically reflected in the Object Tree. • You can group application objects any way you like. • Projects can be generated automatically using the project filter, or the project group's properties. • The project remembers the state you last left it in: which windows were open, which branches expanded and so on. • You can compile and save all project objects at one time. A number of shared projects are supplied with your Axapta installation.

Saving your work The MorphX save and compile strategy ensures that • You are always aware when you should save your work • Your work is automatically compiled when required. When you have created an application object in the tree that has not yet been saved, the system indicates this by adding a red line to the object.

Pic. 3-2 When you subsequently save the object, the system automatically compiles it when necessary. If you compile the object rather than save it, the system automatically saves as well. The red indicator line disappears as soon as the object has been saved. If you neither save nor compile your application object but immediately try to execute it (for example by clicking Open in the shortcut menu), the system automatically compiles and saves your object.

The MorphX property sheet Properties are displayed in a secondary window that remains open on your screen until you deliberately close it. The window always shows the properties on the node currently in scope; this means that when you traverse the tree, the contents of the property sheet automatically change.

 21

To display the Object Tree and the property page next to each other, click Tile in the Windows menu

 Columbus IT Partner Russia, ApS

Navision Axapta

Properties and categories Typically the number of properties grows as you expand the tree to increasing levels of detail. On the deepest levels the number of properties is frequently about 40. To improve your overview the properties are grouped in categories. An example of a category could be the properties defining the position of a control on a form, that is left, right, width, height, and whether the control should be visible on the form. Categories are displayed alphabetically sorted.

Modifying a property You can modify a property simply by clicking it and selecting a new value from a list, or entering the new value. You can also modify any property directly through your X++ code.

Colors in the properties window The property editor uses two colors: pale red and pale yellow. Pale red indicates that the property is an identifier, in other words, the name of an application element. An example would be the name of a form. Pale yellow identifies all texts that should have been entered as a label but were not.

Common properties If you select several objects in the tree, you can see their common properties and the properties that have identical value. Common properties for which the current values differ are blank. Using this technique you can also modify the properties of several objects at a time.

MorphX concepts you need to know Some central object-oriented mechanisms and terms appear repeatedly as you develop with MorphX. Below is a brief explanation of the most important ones. MorphX Concept

What is it and how does it work?

System class

A system class is an interface to functionality defined in MorphX, for example to create, or run a form.

Class

A class defines an object’s interfaces. It instructs or explains how to construct an object of a particular type. An essential characteristic of a class is that you can "new" it, or in other words, create a new instance (an object) of the class. Forms are an example of a class: MorphX has a class definition that prescribes exactly what happens when a form object is created.

Controls

A control is a graphical object, such as a text box, a check box, a command button, or a rectangle, that you place on a form or report when designing it to display data, perform an action, or make the form or report easier to read. There are approximately 20 different controls and each is defined by about 50 properties.

Data Source

A data source holds those data variables that a form or a query uses. These data variables may be one or more tables, or individual fields from tables.

Designs

A Designs node provides access to define the layout of a form or a report.

Encapsulation

Encapsulation means that data in the system are hidden behind methods and can be changed only by the methods.

Final

Final is a class or method modifier that defines that the class or method cannot be extended (overridden).

 Columbus IT Partner Russia, ApS

22

Navision Axapta Inheritance

Inheritance is a central concept in MorphX. It means that what you define at lower levels in the system is automatically ”inherited” by higher levels. An illustration of the hierarchy of inheritance is that your own methods may be built on and extend one of the methods defined in MorphX. In the code this is indicated by the ”super” reference. You can always recognize an inherited method on the down arrow in the method’s icon .

Method or object method

Methods are tasks you can tell an object to do. Methods can be programmed at several levels: • As part of a table • As part of a form Methods for a form may be related to: • The general management of the form such as running the form closing it • The data displayed in the form such as deleting or writing data • Form controls such as moving the cursor • As part of queries • As part of a general class library Initially the methods are only frames that activate MorphX’s methods (indicated by the “super()” call). The small icon in the tree structure indicates that there is, as yet, no user code in the methods. When you have added some code of your own, a small color indicator is displayed in the icon. The color bar is green when your code has no syntax errors, and red in cases where your method has errors. In a method you can • Add code to be executed prior to the method’s main action. • Write you own method or let MorphX handle it (the “super()” call). • Add code to be executed after the method’s main action.

Object

Object is the central MorphX concept. Any form and any control is an object. The database is an object. Objects are created from classes; thus an object is said to be an instance of a class. Objects provide a convenient, logical way to organize procedures and data. Objects are encapsulated which means that they contain both their code and their data. To use an object, you must keep a reference to it in an object variable.

Property

Properties are data that describe an object. Each type of object has different types of properties. A method typically has only a few properties, one of which defines where it is to run. Conversely, a control frequently has about 50 properties which define position, size, color, and so on.

Query

A query is a filter mechanism to retrieve the data you want to see from your database tables. Queries are typically used as the source of records for forms and reports.

23

 Columbus IT Partner Russia, ApS

Navision Axapta

3.2. Application Object Layers Application object layers hold everything in the Application Object Tree. The layers are a hierarchy of levels in the Axapta application source code to ensure that you can make modifications and additions without interfering with the application objects on the level below your own. The idea is that when you make an object modification on one level, the modification overshadows the object on a lower level. You could for example choose to add E-mail information to a standard form. The addition would be saved on your level only; the revised form would replace the standard form but you would always be able to go back to the original one on the level below your own simply by removing the new form. The layers are designed with the Axapta customer groups in mind. Basically three customer groups have an interest in adding and modifying application objects: • Application developers who create the standard application • Business partners • Axapta end users Each of these three groups has two layers in which they can add and modify. SYS

The standard application is implemented at the lowest level, the SYS layer. The application objects in the standard application can never be deleted.

GLS

When Damgaard Development certifies and distributes a solution that has not been developed in-house, this solution is distributed in the GLS layer. GLS is short for GLobal Solutions.

DIS

When the application is modified to match country specific legal demands, these modifications are saved in a separate layer, the DIS layer (for DIStributor). If an application object, for example a form, is modified in the DIS layer the modifications are saved in the DIS layer only and Axapta ensures that the modified version of the forms is used.

LOS

A layer where the distributor can implement local partner solutions. LOS is short for LOcal Solution.

BUS

When a business partner creates his own generic solution, his modifications are saved in the BUS layer and – again – Axapta ensures that the top level application objects are used.

VAR

Customers with a VAR (Value Added Reseller) status may make their own, customer specific modifications to the business partner solution. Such modifications are saved in the VAR layer.

CUS

The supervisor or administrator of an end user installation may wish to make modifications generic to the company. Such modifications are saved in the CUS (CUStomer) layer.

USR

Lastly the end user may wish to make his very own modifications, for example his own reports. His modifications are saved in the USR layer.

Each layer is saved in a separate file called Ax.aod, for example Axsys.aod for the SYS layer, Axdis.aod for the DIS layer and so on. The .aod extension is an acronym for Application Object Data file. In addition to the six layers, each layer has a patch layer. For each layer, there is a corresponding label file.

 Columbus IT Partner Russia, ApS

24

Navision Axapta

Using the top level version of an object at all times A single index file called Axapd.aoi automatically ensures that the top-level version of an application object is always used. The USR layer is the top layer and the SYS layer the bottom one. This means that when a user opens for example a form object, Axapta first checks whether there is a USR version of the form, next whether there is a CUS version, next for a VAR version and so on until finally the SYS version is used.

USR

CUS

VAR

BUS

LOS

DIS

GLS

SYS

The majority of application objects (table, field, index, and enum type, Extended Data Type, feature key) have unique id numbers in addition to names. Axapta uses eight number series corresponding to the eight layers. SYS layer object numbers:

1-7999

GLS layer object numbers:

8001-15999

DIS layer object numbers:

16001-17999

LOS layer object numbers:

18001-19999

BUS layer object numbers:

20001-29999

VAR layer object numbers:

30001-39999

CUS layer object numbers:

40001-49999

USR layer object numbers:

50001-59999

When an object is initially created, Axapta automatically manages ids and assigns a new id according to the above table. Note, though, that when you modify an existing object, the object keeps its original id and is not assigned a new id in your layer. 25

 Columbus IT Partner Russia, ApS

Navision Axapta

Layer benefits The fact that each layer is saved in a dedicated file means that it is easy to locate the file to backup. It also means that you can easily remove undesired modifications: you can simply delete the layer file.



In that case you should also delete the index file to make the system re-generate it.

The layers ensure that: • Any user of the Axapta application, whether a distributor, a business partner or an end user, can customize the Axapta application to suit his/her needs. • The standard application is never overwritten. • When you delete an object, you delete it in the current layer only.

Additional patch layers In addition to the eight layers, each layer has a patch layer. The patch layers are called SYP, GLP, DIP, LOP, BUP, VAP, CUP, and USP. The patch layers are designed to make it easy to incorporate updates in your current application. The basic idea is that when a minor update or correction is made, it is distributed in a patch file, for example Axsyp.aod. When a patch file is present, the modified objects in the patch file take precedence of the regular objects and are automatically used.

USP USR CUP CUS VAP VAR BUP BUS LOP LOS DIP DIS GLP GLS SYP SYS

The patch files used the same number series as the regular files.  Columbus IT Partner Russia, ApS

26

Navision Axapta The major benefit of the patch layer concept is that you can easily create and distribute an update - for example using the Internet – without interfering with the existing application. When you subsequently incorporate the update in the regular layer file, you can simply delete the patch file (Ax??p.aod ) and the index file (Axapd.aoi).

Viewing layers in the application during development In the Application Object Tree, you can choose whether you would like to see what layer the individual objects belong to. The layer is given in parenthesis after the object name.

Pic. 3-3 To choose a view, click Options... on the Tools menu. Click the Development tab. The field labeled “Application object layer” defines your current view. View

What is displayed?

Show no layers

No objects are labeled with layer indication.

Show all layers

All objects are labeled with layer indications for all layers in which they exist. This means that if an object from the standard application (the SYS layer) was modified in for example the DIS and VAR layers, the object would be labeled (sys, dis, var)

Show highest layer

All objects are labeled with layer indication for the highest layer. All objects are labeled. If an object from the standard application (the SYS layer) was modified in for example the DIS and VAR layers, the object would be labeled (var)

Show corrected layers

Only objects that have been modified in the current layer or a higher one are labeled and only with indication for the highest layer. This means that if an object from the standard application (the SYS layer) was modified in for example the DIS and VAR layers, the object would be labeled (var)

27

 Columbus IT Partner Russia, ApS

Navision Axapta Show all from corrected layers

Only objects that have been modified in the current layer or a higher one are labeled but with indication for all layers. This means that if an object from the standard application (the SYS layer) was modified in for example the DIS and VAR layers, the object would be labeled (sys, dis, var)

You can see the layer you are currently modifying in the system’s status bar.

Using the Layers command When an application object exists in several layers, the Layers command is enabled in the shortcut menu on an application object (table, macro, class, form, report, query, and menu). Click Layers to view each application object as a separate instance. For example, if you have modified the Address form in the standard application in the USR layer, clicking Layers on the Address object displays two instances on the form.

Pic. 3-4 All modifications are made in the top layer only. Tables and classes are special in the sense that when you modify a single method, only that method exists in several layers. So clicking the Layers command on a modified method displays only that method in two instances.

Pic. 3-5 Note that when you have modified, you can only compile in the current layer- there can be no modifications in other layers that makes re-compiling necessary. Tables and classes are also special in another sense: when you have modified an object, for example the Address table, and next click the Layers command, then all other layers but the current one “disappears”. Only information saved with the table or class (and not in the application object layer file) is shown.

Pic. 3-6 As you can see from the above example, DeleteActions are saved with the table and consequently visible for the SYS layer also.

 Columbus IT Partner Russia, ApS

28

Navision Axapta

Setting the current layer The current layer is set when Axapta is installed. Using the Axapta Configuration Utility (ACU) you can view and modify the current level. Note that you cannot modify the original configuration – you must create a copy and modify that – and that you must supply a password before you are allowed to modify the “Appl. object layer”.

Pic. 3-7

Exporting objects from a selected layer 1. Open the Application Object Tree and make the root node the current one. 2. Choose Export on the Command menu. 3. In the Export dialog, select the layer checkbox and choose the relevant application object layer from the list.



You can always see the current layer in the status bar.

Use the Browse button to find a location and a name for the export file. The extension for an export file is .xpo. 4. Click Export to perform the export with the selected options. Now the export process begins, exporting all objects from the selected layer.

Tables and classes are special cases Tables and classes are special cases in the sense that they may have sub nodes that are saved in different layers. For example, the table Tab1 in the SYS layer may have a field, Field1, that exists both in the SYS and in the USR layer. 29

 Columbus IT Partner Russia, ApS

Navision Axapta When you export the USR layer, the Tab1 tables is exported as well but the export file will hold only the description of Field1 and not the remainder of the table. When Tab1 is subsequently imported, only Field1 is affected.

Tips

.

If you want to move X++ code to another layer Follow the procedure below if you want to move X++ code to another layer while keeping your data: 1. Start Axapta in the layer the X++ code is to be moved from. 2. Use the Export command in the Application Object Tree shortcut menu to export the X++ code to an .xpo file. 3. Use the Data export/import command on the Administrator menu (Database submenu) to export data in the relevant tables. Relevant tables are the tables to be moved to another layer and possibly other tables with references to the tables you move. 4. Delete the X++ code in the current layer. 5. Click Synchronize in the Application Object Tree shortcut menu. Axapta now updates following your deletes in step 4. 6. Exit Axapta. 7. Start Axapta in the layer that to which you want to move X++ code. 8. Use Import on the Command menu to import the .xpo file you created in step 2. 9. Click Synchronize in the Application Object Tree shortcut menu to synchronize the tables you have just created. Now you have the tables you have in the initial layer, only with a new Id. 10. Use the Data export/import command on the Administrator menu (Database submenu) to import data. The data import does not use Ids but is based on table and field names to identify the data import target.

If you want to move tables to another layer Tables in Axapta are identified by their IDs. Different ranges of IDs are used for different application object layers. For example, IDs in the range 1-7999 are used for SYS-layer objects while objects in the VAR-layer use IDs in the range 30001-39999. It is important to realize this if you want to move table definitions and the data the tables hold from one application object layer to another, for example from the CUS to the DIS layer. Follow the procedure below if you want to move tables to another layer while keeping your data: 1. Start Axapta in the layer the tables exist in. 2. Export data from the tables you want to move. Use the Data export/import command on the Administrator menu (Database submenu) to export data.



Choose Binary format in the Export options dialog. Binary exports are faster and container fields are preserved intact.

3. Export the tables you want to move. Select the tables to export in the Application Object Tree and use the Export command on the shortcut menu to export the tables to an .xpo file. 4. Delete the tables from the Application Object Tree. Use the Delete command on the Application Object Tree shortcut menu to delete the tables.  Columbus IT Partner Russia, ApS

30

Navision Axapta 5. Exit Axapta. 6. Re-start Axapta in the layer you want the tables to be present in in the future. Use the Axapta Configuration Utility to select layer. You can see the current layer in Axapta's status bar. 7. Import the tables using the Import command on the Command menu. Following the import, the tables are present in the Application Object Tree. 8. Synchronise the database. Select the Data Dictionary node and click Synchronize on the Application Object Tree to synchronize the database. 9. Import data using the Data export/import command on the Administrator menu (Database submenu). The data import places data in the correct tables with their new IDs.

3.3. Working with projects A project is a subset of the Object Tree that allows you to group the components you are currently working on. A project is either private or shared. A private project is only available to the user who created it. In contrast, a shared project is available to all users, and can be used as a tool for workgroups to manage their work. Because a project is a subset of the complete tree, everything you create or modify in your project also automatically exists in the tree. Besides providing an overview of the process you are currently working on, using projects offer additional advantages. • When a node is edited in the project, the modifications are also automatically reflected in the Object Tree. • You can group application objects any way you like. • Projects can be generated automatically using the project filter, or the project group's properties. • The project remembers the state you last left it in: which windows were open, which branches expanded and so on. • You can compile and save all project objects at one time. A number of shared projects are supplied with your Axapta installation.

Open a project 1. Click Open project on the File menu, or click the project icon on the toolbar. This will open the project window with all projects.

31

 Columbus IT Partner Russia, ApS

Navision Axapta

Pic. 3-8 2. Expand the Private or the Shared folder. 3. To open a project, double-click the one you want to work with. You can also right-click the project, and then click Open on the shortcut menu.

Create a new project 1. Click Open Project on the File menu This open the Projects window with the Private and Shared projects.

Pic. 3-9 2. Right-click either the Private or the Shared node, and select New Project. This creates a new, empty project that you can give a suitable name. 3. Open the project using the Open command on the shortcut menu, or the open icon on the project toolbar.

Pic. 3-10 Now you can begin working with the project. Use a drag-and-drop operation to include objects from the Application Object Tree in the project.



Alternatively, use the project filter to create the project's contents.

Create new objects using the New command on the shortcut menu. Note in particular the Group command, which is a grouping mechanism to enhance your overview of your workspace, and to allow you to structure your project.

 Columbus IT Partner Russia, ApS

32

Navision Axapta

Pic. 3-11 The project is automatically saved when the project window is closed.



Use the ProjectGroupType property on a project group to change the icon in the project tree to the ones used in the AOT. However, using a specific icon does not enforce the corresponding object to be of a specific type, and any type of objects can be included.

Create a new ptoject using the project filter funtion Using the project filer function you can set up criteria for searching the Application Object Tree. The objects located in the search are automatically included in the project. 1. Click Open Project on the File menu. This open the Projects window with the Private and Shared projects. 2. Right-click either the Private or the Shared node, and select New Project. This creates a new, empty project that you can give a suitable name. 3. Open the project using the Open command on the shortcut menu, or the open icon on the project toolbar. Now you can begin working with the project. 4. Click the filter icon on the project toolbar to open the Project Filter dialog. 5. Use Append or Overwrite to define how the system should handle the project. Select Overwrite to have the project's former contents deleted before new objects are added. 6. Click one of the buttons below the Grouping heading to define how the system should group the objects in the project. If you select AOT, the system automatically creates nodes labeled like the nodes in the Application Object Tree, for example Classes, Forms, Menu Items. If you select By user, the system automatically creates nodes labeled with user identification. 7. Click Select to define the query to be used. The query can locate objects in • the application object database (UtilElements table), • the application help texts (UtilApplHelp table), • the application delveloper help texts (UtilApplCodeDoc table), and in • the system help texts (UtilCodeDoc table). 8. Click OK to close the query dialog and save query. 9. Finally click OK in the Project filter dialog to generate a project according to the query defined.

Autogenerate a project group Use New Group on the project shortcut menu to add a heading node to your project. Next you can add application objects that belong under the heading and thus gain an overview of the subset of the AOT that you are curretnly working on. The heading might be the name of the current project, the name of a project member, or the name of a feature. You can choose to drag-and-drop objects from the AOT to your project group, or you can autogenerate the contents of a group. 33

 Columbus IT Partner Russia, ApS

Navision Axapta

To autogenerate the contents of a project group 1. Create a new project, or open an existing one. 2. Click New Group on the project shortcut menu to create a group in the project. 3. In the group's property sheet, use ProjectGroupType to select the application object type to include in the project, and use GroupMask to enter a regular expression to select objects. An example: Set ProjectGroupType to "Forms", and enter "BOM" in the GroupMask property. The project group will now have all forms with the string "BOM" in the name.



The Help information for the Match system function in the Axapta internal help system has an overview of the syntax of regular expressions.



Autogenerated projects are refreshed each time Axapta is started. Objects that have been added manually to an autogenerated group are removed from the project when the project is refreshed.

Project tips Drag-and-drop If you drag a project from the Private node to the Shared node, the project is moved. If you drag a project from the Shared node to the Private node, a copy is created. This is because others might want to use the shared project.

Delete or remove When you delete an object in a project, the object is also deleted in the Application Object Tree. Before an object is deleted, however, a warning is displayed:

Pic. 3-12 Use Remove to delete an object from the project only.

Naming Private and shared projects may have identical names.

3.4. Using the editor You can attach your own X++ code to various objects in the system such as forms, classes, reports, queries, and to individual tables in the database. To open the X++ editor, double-click on a method name or click Edit in the shortcut menu. The name of the selected method is displayed on a tab. The editor makes it easy to work on several methods at the same time. Double-click another method within the same class, and a new tab is created.

 Columbus IT Partner Russia, ApS

34

Navision Axapta

Pic. 3-13 In the example above, there are several tabs in the X++ editor. To change from one method to another, click the tab or use the arrow buttons. The editor lets you perform standard Windows editing functions like copy, cut ,and paste. Undo and redo is available ten actions back. The editor has shortcut menus (activated by right-clicking) where the available commands depend on whether you have selected text in the editor. Use F1 to have context-sensitive help on a system class. Use the ESC-key to exit the editor. If you have made changes, the system asks whether you would like to save.

Editor color codes These colors are used for X++ code in the editor: Color

Used for

Color

Used for

Blue

Reserved words

Green

Comments

Red

Strings

Black

Everything else

Use editor shortcut keys To make it easier and faster to use the editor, use these shortcut keys: When you want to...

Press

Indent selection

TAB

Extend selection/remove indent

SHIFT+TAB

Open Help on a class

F1

Delete the previous word

CTRL+BACKSPACE

Open the Find/Replace dialog

CTRL+F

Find the next occurrence

F3

Compile

F7

Compile and close a method

F8

Set and delete a breakpoint

F9

Replace

CTRL+R

35

 Columbus IT Partner Russia, ApS

Navision Axapta Jump to a method

CTRL+SHIFT+SPACEBAR

Mark a column

ALT+O

To undo and redo

Press

Undo

CTRL+Z (latest ten actions)

Redo

CTRL+Y (latest ten actions)

To go to...

Press

The next method

CRTL+TAB

The previous method

CTRL+SHIFT+TAB

To look up...

Press

A label

CTRL+ALT+SPACEBAR

A Definition

CTRL+SHIFT+SPACEBAR

Properties and methods

CTRL+SPACEBAR

To list...

Press

Tables

F2

Classes

F12

Types

F4

Enums

F11

Reserved words

SHIFT+F2

Built-in functions

SHIFT+F4



You can also use the toolbar buttons in the editor to enable the facilities listed above and to save you code.

Editor lookup facilities The position of the cursor defines the type of information the system displays when you click the Lookup command. If you have positioned the cursor on an object...

 Columbus IT Partner Russia, ApS

The system displays a list of the object’s data and methods. If, for example, you click Lookup on a table object, you will see the table’s fields and methods.

36

Navision Axapta

If you select an object method from such a lookup list, the system inserts the method name followed by a begin parenthesis. Also, the method’s parameter profile is shown in a ToolTip. Tip If you type :: after the name of a class, table, enum, or map, the editor looks up static methods or Enum values as appropriate. If you have positioned the cursor on an object that has no data or methods...

The system displays a ToolTip informing about the object type. If for example you click on an object of type ToDate, you will see the information “Extended Data Type: ToDate (Date)” in the ToolTip.

The ToolTip disappears when you click elsewhere or move the cursor. If you have positioned the cursor on a space or on a word about which the system has no information...



The system displays “No Lookup Information” in the status bar.

The automatic IntelliSense is an option you can disable. Click Options on the Tools menu, and then click the Development tab.If you have disabled the automatic IntelliSense, you can use CTRL+SPACE to look up information.

Printing your code Print source code directly from the Application Object Tree by clicking the Print command on the File menu. This prints the contents of the current method.

Editor scripts: What they are and how they work Editor script is a way to customize the X++ code editor to make it easier and quicker to perform frequent tasks. Such tasks could for example be to insert a header with the time, date, and user identification, to mark a block of code as comments, or to add information about the place where the method is executed. Editor scripts are available from the X++ editor shortcut menu from the Scripts submenu. The scripts are created by writing X++ code so anything that you can code in X++, you can do in an editor script.

3.5. Using the Debugger To activate the debugger automatically when code is compiled 1. Click Options on the Tools menu. 2. Click the Development tab. 37

 Columbus IT Partner Russia, ApS

Navision Axapta 3. Define the system’s behavior when executing code by setting the Debug mode.

Pic. 3-14 If you set the property to...

It means that...

No

The debugger is never activated.

Always

The debugger is activated when the first code is executed. As code is executed when the system starts, the debugger is activated upon startup.

On Breakpoint

The debugger is activated only when a breakpoint is encountered.

The line in your code where the debugger breaks, changes color (to a dark blue).

To set breakpoints You can set a breakpoint in the debugger, and in the X++ code editor. 1. Position the cursor where you would like to insert the breakpoint. 2. Click the breakpoint icon in the title bar or press F9. The line changes color (to a dark red) to indicate that a breakpoint has in fact been inserted. If you have inserted an invalid breakpoint, this is indicated with a gray color. Note that invalid breakpoints are not marked in the editor. To see a list of breakpoints, click Breakpoints on the Edit menu. Alternatively, you can press SHIFT+F9. In the breakpoints list, delete breakpoints by using the DELETE key.

Use debugger shortcut keys To make it easier and faster to use the system’s debugger, use these shortcut keys: When you want to...

Press

Run the debugger

F5

Set or delete a breakpoint

F9

Show breakpoint table

SHIFT+F9

 Columbus IT Partner Russia, ApS

38

Navision Axapta Step into

F8

Step over

SHIFT+F8

Step return

CTRL+F8

Open or close the variables window

ALT+2

Open or close call stack window

ALT+3

Open or close system variable window

ALT+4

Switch line numbers on/off

F4



You can also use the toolbar buttons in the debugger to enable the facilities listed above.

The keys F5, F9 and SHIFT+F9 can also be used in the editor.

Using debugger information When you have chosen to execute your code with debug information, the code lines are displayed in a debug window.

Pic. 3-15 With the X++ debugger you can • Execute code • Step through the individual code lines • Insert breakpoints • Open a variable window displaying a line for each variable with name, type, scope and value. • View the call stack • View system status • Display line numbers in your code. You switch on these functions by clicking the toolbar buttons or by using shortcut keys.

39

 Columbus IT Partner Russia, ApS

Navision Axapta

3.6. Working with more languages Ladels: What they are and how they work When you create a database table you may, for example, have a field named CompName, and another one called ZipCode that indicate the kind of data they hold. However, in the form presented to the end user where he views and enters information in the table, you may want to display other texts, for example “Company name”, and “Postal code”. To do so you define a label for each of your database fields, or for the Extended Data Type used. Label is a property on an Extended Data Type and on a database field.

Pic. 3-16 You can also define a label as part of the properties for each control on a form or from X++ code, but the advantage of having set the Label property on the database level is that it is inherited on all forms where the table is used as a data source. Whenever possible, you should define your labels on your Extended Data Types. The background color of the label property's value field is pale yellow until a label has been defined. A label is identified by a unique label ID that consists of • an at sign, • a three-letter label file ID, and • a number, for example @SYS58401. The three-letter label file ID is part of the label file name and is SYS or SYP for any label supplied with the standard system. The standard label file is called AxSYS.ald where country is an abbreviation of the language used, for example En-us for American English, En-gb for British English, or Da for Danish. If you create a new label file, the three-letter label file ID may be chosen freely. The number is assigned and managed by the system. A label has the same ID in all the languages you work with. If you have created a label with the label ID @ABC58401 in your current language, the label is automatically created in all laguages you work with. This means that if you work with an American and a German label file, AxABCEn-us.ald and AxABCDe.ald, the label @ABC58401 exists in both of them.

Axapta standard for a label Every user interface text must be defined using labels.  Columbus IT Partner Russia, ApS

40

Navision Axapta Context information must be given in American English in the comment field. This is particularly important for shorter labels where the context is not completely clear. A new label must be created for each new semantic use. A label must have an uppercase first letter and all other letters in lowercase. When possible, a label should be created on an Extended Data Type rather than a field. If an existing Extended Data Type can be reused but the existing label is considered unsuitable, create a new Extended Data Type based on the former one and change only the label.

Creating a label 1. Open the property sheet for the object you want to define a label for, for example an Extended Data Type, a database field, or a control. The background color of the label property's value field is pale yellow until a label has been defined. You can also create a label from X++ code. To do so, click the insert label icon in the X++ editor. 2. Click the Label property and enter the text to be displayed on the user interface. If a label has already been entered you will see the label id (for example @SYS1109) when you click the property field. 3. Click the label icon to open the label dialog. The system now searches all available label files to check whether the text you entered already exists as a label. This is to ensure that identical labels are not accidentally created. If the label does not exist, use CTRL+N to create it. Optionally, you can enter a description. 4. Click Paste label to insert the new label.



To delete the current label, use ALT+F9 or click the delete record button on the toolbar.

The label dialog The label dialog for searching, creating, and inserting labels is opened when you click on a Label property in a property sheet, or the insert label icon on the X++ editor's toolbar.

Pic. 3-17

41

 Columbus IT Partner Russia, ApS

Navision Axapta Label tab Find what

The text to search for in the label system interface. The search locates all instances of the string. To create a new label with this text, use CTRL+N.

Language

Select the language you want enter the label text in. The label ID is automatically reserved in all language files.

Advanced tab Auto search

Select Auto search if you want the system to automatically begin searching when the label dialog is opened.

Auto create

Select Auto create if you want the system to automatically create a new label when no match is found during the search.

Label file ID

Select the label file you want to create new labels in. Use the Label File Wizard to create a new label file. Once a label file is created, the label file ID is automatically available in the list.

Select languages to be shown in the label dialog

Select one or more languages to be able to see translations of the current label.

Paste label

Paste the current label to the property sheet or the X++ code.

Used by

Open the cross-reference system to find out where the current label is used.

The search buttons Click this

To do this

Click this

To do this

Find now

Begin your search.

Stop

End your search.

New search

Begin a new search. If you click this button, you lose the results of your previous search.

Line breaks in labels A label may hold one or more line breaks. To format such labels properly use the strFmtLB method on the Global application class. The method takes a label as parameter and returns a string with the proper line breaks. An example box::yesNo(strFmtLB("@SYS59537"),DialogButton::No);

Creating a label file The system is shipped with a label file called AxSys.ald that exists for all available languages, for example AxSysEn-us.ald, AxSysDa.ald, and AxSysDe.ald. This file is updated whenever a new version is released. New texts for service packs may be released in a label file called AxSyp.ald. When you need to create new user interface texts, you should create a label file of your own. To help you do that, Axapta includes a label file wizard. 1. On the Tools menu, point to Development, then Wizards, and click Label File Wizard.

 Columbus IT Partner Russia, ApS

42

Navision Axapta



To ensure that only valid file names are used for label files, always use the Label File Wizard to create new files and languages. The label editor cannot open a label file that has an invalid name and the user will be presented with a message to that effect if a label file has been renamed.

2. The wizard asks you select a label file ID and one or more languages. If you do not want to create a new label file ID but just add a new language, you do not have to enter a file ID in the wizard dialog. The language you add is added to all your label files. If, for example, you have these label files AxABCEn-us.ald and AxDEFEn-us.ald and want to add Danish as a new language, you do not enter any label file ID but select Danish in the list of languages. When the wizard finishes, you have these additional files: AxABCDa.ald and AxDEFDa.ald



You can add but not remove languages from the initial list of selected languages. The list is created on the basis of other language files present on your installation. For example, if the language files AxSysEn-us.ald, AxSysDe.ald, and AxSysDa.ald are present when you are creating a new language file, the wizard will present English(United States), German, and Danish in the list of available languages. You can add more languages but you cannot remove the three original ones.

Click Create new language if you need to create labels in a language not present in the list of available languages. 3. Click Finish to create a label file for each of the selected languages.

3.7. Working in MorphX System classes: What they are and how they work A system class is functionality implemented in MorphX, and used by MorphX, that has been exposed through an interface so you can use it. The fact that it is implemented in MorphX means that you cannot see the actual implementation (the code lines); you just have the calling syntax (number and type of parameters), and a description of what the function actually does. The fact that it is used by MorphX means that the system classes hold the functions that are activated whenever you use the tree to create your application. There are about 150 system classes in the system. FormDesign, shown below, is just one example of a system class. The system uses FormDesign when you define the layout of your form in the Designs node in the Application Object Tree. For example, when you click New CheckBox in the Application Object Tree, the system activates the ControlName method with a CheckBox type control as parameter.

43

 Columbus IT Partner Russia, ApS

Navision Axapta

Pic. 3-18 As the icons indicate, a system class typically has • Properties (or rather member functions to set properties) for example LeftMargin • Methods. All system class methods are final, meaning that no extended class can override the behavior of the method. The system classes allow you to do everything in X++ code possible by clicking nodes and commands in the Application Object Tree. Now, presumably you would not want to design your forms from scratch using X++ code invoking the system classes, and that is not really the intention with the system classes. The system classes are a means of making the system more flexible and dynamic exactly where you need it to be. One typical, and advanced, use of the system classes is to change the application dynamically during runtime. For example, a sequence of forms with choices where the available options in form number three depend on the user's choices in the preceeding forms. Another example of dynamic changes performed during runtime, adding information (an extra column, a subtotal, another header and so on) to an existing report.

Locking the datebase in a multiuser environment When several users have simultaneous access to updating the database a conflicting situation can arise if two users are trying to modify the same application object. The scenario might be as follows: 1. DeveloperA modifies a table by adding a field. 2. DeveloperB also wants to add a new field, so while DeveloperA is making his modification, DeveloperB makes the same one. 3. DeveloperA finishes his table addition, and saves it. What now happens when DeveloperB attempts to save his modified table that does not include DeveloperA’s recent addition? MorphX resolves these types of conflicts by giving each application object a version stamp. When you try to save an application object, the system compares your object’s version stamp to the version stamp of the object in the database. If your object’s version stamp is older than the one in the database, you are not allowed to save. In the scenario described above DeveloperB will probably be quite annoyed when he is informed that he cannot save the work he has just done, even though the system ensures data integrity.

 Columbus IT Partner Russia, ApS

44

Navision Axapta To avoid such situations, use the Lock command when you are modifying an object and you are not sure whether another user is also about to make updates. When you have saved your updates, use Unlock. To make sure that updates are always seen immediately by all users, ensure that Auto-Update has been selected (click Options on the Tools menu and click the Development tab). Use the Refresh command to have the system update the application objects you currently see. Modifications made by other users then become visible.

When a node is locked... When you lock an application object for modifications from other users, a small padlock symbol is automatically added.

The padlock symbol is yellow when you have locked the object, and red if it has been locked by another user. When you try to save modifications made to an object locked by another user, a message is displayed informing you that the node has been locked and the name of the user that has locked it. When you have finished working with an object that you have locked, unlock it to make it available to other users. If you are logged on as supervisor (the default user name is “admin”), you can unlock other users’ locks.

Using the fundamental classes The fundamental application classes in Axapta are listed at the bottom of the Classes list in the Application Object Tree. To indicate that the classes are special, their icons differ from that of the other classes.

Pic. 3-19 The classes extend a system class of almost the same name, only prefaced with an 'x'. Most classes have a global variable used to access the class. The global variables need no variable declaration and are pre-instantiated. The classes each serves a different purpose and the extent to which you will need to use them vary. Using the classes, you should • Always use the application classes rather than use the system classes directly. • Use the variables to access the classes. • Never instantiate the classes. The Session class must be new'ed, though. • Specify the class name to access static methods. Application class

System class

Global variable

Runs on...

Session

xSession

(none)

client and server

Application

xApplication

appl

server

45

 Columbus IT Partner Russia, ApS

Navision Axapta Company

xCompany

app.company()

server

Info

xInfo

infolog

client

ClassFactory

xClassFactory

classFactory

client and server

Global

xGlobal

(none)

client and server

An example: Below is an example of a job that uses the global classes. You can safely create a new job in the Application Object Tree and copy-paste the below code lines into the job. static void GlobalClasses1(args a) { treeNode treeNode;

args args; formRun formRun;

// appl variable print appl.buildNo();

// "company" variable appl.company().reloadRights();

// infolog variable treeNode = infolog.findNode('\\forms\\custTable');

// classFactory variable args = new args(formstr(vendTable)); formRun = classFactory.formRunClass(args); formRun.init(); formRun.run(); formRun.detach();

// global class info("This is a message on the infolog"); pause; }

Using global variabies The need for global variables often arises because of flawed implementation design. However, if used for caching purposes global variables can provide performance boosts. This topic describes how you can implement a global variable with zero maintenance during upgrade.

 Columbus IT Partner Russia, ApS

46

Navision Axapta

Why use this approach? Using the approach described below, no standard application classes are modified and consequently no conflicts with the subsequent version are introduced. This means stable code with zero upgrade maintenance and fast three-tier performance.

How to set the variable First get the globalCache variable located on the ClassFactory class: SysGlobalCache globalCache = classFactory.globalCache(); Then call set with three parameters: globalCache.set(str owner, anytype key, anytype value); Parameters

Description

Owner

Must be a unique name identifying you as the user. It is recommended to use classIdGet(this) or classStr(myClass).

Key

Is how you identify your variable. This is useful if you need more than one global variable from the same location.

Value

Is the actually value of your variable.

How to get the variable First get the globalCache variable, also located on the ClassFactory class: SysGlobalCache globalCache = classFactory.globalCache(); Then call get with three parameters: value = globalCache.get(str owner, anytype key, anytype returnValue = ‘’); Parameters

Description

Owner

Must be a unique name identifying you as the user.

Key

Is how you identify your variable.

ReturnValue

Is the value you want if the global variable has not been set. This is useful for caching purposes. See the example.

Example (from Classes/ImageListAppl) void new() { SysGlobalCache globalCache; if (this.keepInMemory()) { globalCache

= classFactory.globalCache();

imageListAppl = globalCache.get(classStr(ImageListAppl), classIdGet(this), null); } if (!imageListAppl) { imagelist = new Imagelist(Imagelist::smallIconWidth(), 47

 Columbus IT Partner Russia, ApS

Navision Axapta Imagelist::smallIconHeight()); this.build(); imageListAppl = this; if (this.keepInMemory()) { globalCache.set(classStr(ImageListAppl), classIdGet(this), this); } } }

Three-tier considerations Due to the dual nature of ClassFactory, the global variable exists either on the client or the server. The implication is that what you insert on the client side will not be retrievable from the server side. This means potentially less network traffic as it is possible to have the global variable on both sides. You just have to set it twice. If you want to share your global variable across the network and will accept the performance penalty of a client/server call, use the infolog or appl classes instead of ClassFactory. They reside respectively on the client and on the server.

WinAPI (Windows Application Programming Interface) As the name indicates, this class is an application programming interface to Windows functions, for example files management. Primarily, the WinAPI methods access functions in these DLLs: • USER32.DLL Operating system functions to manage the user interface, for example functions to create windows, draw windows, menus, dialog boxes, images, icons and so on. • COMDLG32.DLL Operating system functions to the COMmon DiaLoGinterface, for example Open File, Save File, Print, Choose Color, Page Setup, and so on. • KERNEL32.DLL Operating system functions to the kernel interface, for example functions to start processes, threads, timers, file management, memory, string manipulation, and so on. • ADVAPI32.DLL Operating system functions to advanced kernel interface, for example functions to encryption, services, user profiles, security, registry, and so on.

Where to use the WinAPI class When Windows-related functions are needed, methods to access them might be in this class. If a function is missing, but you know it is in the WinAPI class is a good place to look to see how DLL functions are called.

 Columbus IT Partner Russia, ApS

48

Navision Axapta

3.8. Securing date MorphX provides a variety of different methods you can apply to secure your data. • Restrictions on individual tables and fields. • Limiting the availability of application features. • User-level security, which can be used to limit what parts of the database the user can access or change. • Non-modifiable information.

General access restrictions on tables and fields When creating a table in your database you can restrict the availability of the data it holds. You do this by modifying a table property named MaxAccessMode that on one end of the scale can bar all access, and on the other end provide full access to create, modify and delete data. The restrictions defined here apply to all users. Setting the MaxAccessMode property restricts what the user can see in forms and reports. You can also limit access to modifications on individual fields in a table. A field has two modification properties, AllowEditOnCreate and AllowEdit. The first one determines if the user is allowed to enter data in the field when a new record is created and the second one if the user is allowed to modify data in an existing record.

Customizing by limiting application features Use feature keys to enable and disable application functionality to customize the application to the users’ needs. One feature key could for example enable all features to do with general ledger functions. The ledger feature key could have child feature keys enabling for example feature to do with balance sheets, coverage, or budgets. A whole range of feature keys have been defined in the Axapta application. The feature keys are automatically enabled when the system is first started yielding the system 100 percent functionality. In addition to the advantage of having an application that is customized to the users’ requirements, using feature keys also yields a faster system. This is due to the fact that when you de-select features, the database tables and fields supporting those features are not generated. The result is less database management and lesser storage requirements.

User-level security The most flexible and extensive method of securing data is called user-level security. This form of security is similar to methods used in most network systems. Users are required to identify themselves and type a password when they start the Axapta system. Within the workgroup information file, they are identified as members of a group. Axapta provides a default user named “Admin” who is a member of the group by the same name, but additional groups and users can be defined. Permissions are granted to groups to regulate how they are allowed to work with each object in a database. For example, members of a group named “Users” might be allowed to view, enter, or modify data in a customers table, but not be allowed to change the design of that table. The “Users” group might be allowed to only view data in a table containing order data, and be totally denied access to a payroll table. Members of the “Admin” group have full permissions on all of a database's objects. You can set up more fine-grained control by creating your own group accounts, assigning appropriate permissions to those groups, and then adding users to those groups. Feature keys constitute the primary way to give groups various permission levels in the Axapta application. Having configured feature keys to define what features the application should include, the keys are used for security purposes to grant permissions to the individual groups. The main reasons to apply user-level security are to: 49

 Columbus IT Partner Russia, ApS

Navision Axapta • Allow users to do their designated tasks only. • Protect sensitive data in the database. • Prevent users from inadvertently breaking an application by changing code or objects on which the application depends. Axapta also offers another way to configure user-level security in that you can define user group permissions for individual tables and fields.



The Axapta security system lets the user see only what he has access to, and handles the appropriate access level for each user. Security is applied on the user interface, that is, when the user access Axapta through menus, menu items, reports, and forms. Access through X++ code is not subject to the security system.

View but not modify... To protect sensitive data, you can make information visible without making it modifiable. When designing forms to display and enter data from the database, you can limit the access to modify selected fields. You do this by disabling the control that is bound to the field you want to protect. In this manner the database information is visible but not modifiable. Use the Enable property to disable/enable the control.

Feature keys: What they are and how they work Feature keys are application objects located beneath the Data Dictionary node in the Application Object Tree. You use feature keys to disable features in the application and to control user group access to specific features. Initially the Axapta application has the complete range of business management features. The primary purpose of using feature keys is to present Axapta users with precisely the features they use and avoid loading and managing functions they do not want. Once the subset of Axapta features is defined, user groups are given access to those features as part of the security setup. To define a feature key the first task is to identify the application objects that belong together and that should be enabled or disabled as a group. One such group for example could be all tables and menu items that have to do with ledger balance sheets, another group could be tables and menu items that have to do with ledger closing. Having identified the two groups, you define two feature keys, LedgerBalanceSheets and LedgerClosing, and set each key on the appropriate tables and menu items. Now you can enable or disable the group of features related to ledger balance sheets just by toggling the LedgerBalanceSheets feature key. In addition to tables and menu items, you can also attach a feature key to Extended Data Types, Base Enums, indexes, individual fields, menus, and form controls. Both ledger balance sheets and ledger coverage, along with a number of other functions, belong to the same major group of functions that deal with ledger as such. To reflect this structure, you can create a Ledger feature key that is the parent key to all functionality dealing with ledger. In the illustration below, you can see that Ledger is the parent of a whole range of feature keys. You can now enable or disable all ledger functionality by toggling the Ledger feature key.

 Columbus IT Partner Russia, ApS

50

Navision Axapta

Pic. 3-20 With the above feature keys structure you can • Enable the complete set of ledger functions • Enable ledger functions, but disable the functions that have to do with ledger account references, ledger allocation, ledger alternative accounts and so on. When you have created the appropriate feature keys, you apply them on the relevant application objects by setting the FeatureKey property. In the standard application for example, the Ledger feature key has been applied to the LedgerTable table, to the LedgerBalances table etc., the LedgerAllocation feature key has been applied to the LedgerAllocateTrans table, and to the LedgerAllocation table etc. There are several advantages to using feature keys to manage application functionality: • The user’s working environment does not become clouded with features and facilities he does not use. • As tables and fields that have been disabled through the feature key system are not created in the database, database load decreases yielding a positive influence on performance. When you have defined feature keys and applied your keys to application objects, use the Feature key setup form to view your feature key hierarchy and to turn keys on and off. • A default setup is automatically loaded when the system in installed. As part of the installation process, you are presented with this setup and given the opportunity to disable individual keys. When you define a feature key, you also define where the key should have effect. A feature key may enable or disable features • in the user interface only, • in the database or • in the user interface as well as in the database.

User interface When a feature key that has effect on the user interface is activated, this means that application objects grouped under that key are visible in the user interface. When the feature key is not activated, the objects, for example menu items, automatically disappear from the interface.

51

 Columbus IT Partner Russia, ApS

Navision Axapta

Database Activating a feature key that has effect on the database means that the application objects – typically tables - grouped under the key, exist in the database. De-activating the feature key on the other hand means that the objects are removed from the database. You will probably very rarely use this option.

User interface + Database Most feature keys will probably have effect on both the database and the user interface. When such a feature key is active, the objects controlled by the key are present in the database and in the user interface. When the feature key is not active, the objects do not exist in the database and are consequently not displayed in the user interface.

Define and enable a feature key 1. Define a feature key Right-click the Feature Keys node and choose the New Feature Key command.

Pic. 3-21 Use the property sheet to define the feature key. Normally you will define a feature key in relation to one or more other feature keys. 2. Set the FeatureKey property on the application objects you wish to group under the feature key. You can set the FeatureKey property on an Extended Data Type, a Base Enum, the individual values of a Base Enum, a table, an individual field, an index, a form control, a menu or a menu item. 3. Open the Feature key setup form to ascertain that your feature key has been included. You can open Feature key setup from the Feature keys menu, a submenu on the Administrator menu.

Disabling a datebase feature key A feature key can be of three types: • User Interface • Database or • User Interface+Database The type is defined by the Type property on the feature key. When a feature key of the latter two types is disabled, this has impact on data whereas meta data in your application object database (Ax???.aod) are not affected. For example, if you disable the customer table feature key, all records in the customer table are removed from the database but the customer table application object remains in the application object database. This means that constructions like select custTable where .... will not fail even when no data exist in the database.

 Columbus IT Partner Russia, ApS

52

Navision Axapta

Creating a feature keys hierarchy 1. Right-click an existing feature key and choose the Add Parent Feature Key command. This creates a new, empty node.

2. Use the property sheet to set the FeatureKey property to one of the existing feature keys. The new

node is the parent node. You can use the parent node in the feature key hierarchy to enable or disable all child features.

Feature key organization The full Axapta package consists of a number of series corresponding almost to the submenus on the Main menu. Example of series are Ledger, Bank, Sales, Cust, Purch, Vend, Invent, and so on. To make it easy to set up feature keys, both with respect to global availability of features and with respect to the security system, feature keys are organized in the same manner for all series. The overall idea is to have four basic feature keys for each series: • One that should be used for the basic features within a series, called Default. • One that should be used for features that form extensions to the basic functionality, called Extended. • One that should be used for various minor options within a series, called Options. • One that should be used for features that have a concealed dependency to some other feature, called Dependencies. Each feature key has the name of the series as a preface. Feature key

Type of features the key should be used for

Default

Features that comprise the standard functionality within the series. As these features comprise the standard, basic functionality, they cannot be disabled globally for the system and consequently the Feature property has been set to No. User group access can be defined for the features, though, and the Security property has been set to Yes. Example: Chart of accounts in the Financial series. The Chart of accounts is basic in the series and disabling it would make no sense. On the other hand, users may well have different permissions with repect to the chart of accounts information.

Extended

Features that go beyond the standard functionality but are a natural extension to the basic functionality within the series. As these features are extensions to the basic functionality, they can be disabled globally for the systen and consequently the Feature property has been set to Yes. User group access can also be defined for the extended features, and the Security property has been set to Yes. Example: Periodic journals in the Financial series. Using periodic journals goes beyond basic ledger functionality and constitutes an extension to the necessary ledger features. It is a feature that can be de-selected globally, and for each user group access can be defined.

Options

Specific and detailed options within the series. As these features are optional, they can be disabled globally for the system,

53

 Columbus IT Partner Russia, ApS

Navision Axapta and the Feature property has been set to Yes. The Security property has been set to No because it does not make sense to restrict access to the feature. Example: Contact person for project in the Project series. Having a contact person for projects is a option some companies may choose to use while others will not want it. For the companies that do use it, though, is does not make sense to set up varying degrees of user group access. Dependencies

Features that depend on the availability of some other feature to make sense. The user should not have to make any decisions about these feature keys in either of the feature key setup dialogs. The properties Feature and Security have both been set to No for the Dependencies feature key. Example: Production BOM in the Production series. When the user has chosen production bills of material as part of the production setup, he has implicitly chosen bills of material within Bills of material as well. Therefore bills of material within production is also a child of BOM dependencies.

Tip As both Feature and Security properties have been set to No, dependency feature keys cannot be seen in either of the two dialogs. To be able to see them in the dialogs, right-click to open a shortcut menu and choose Extended tree. Typically the feature keys have the Type property set to User interface + Database which means that when disabled globally from the Feature key setup dialog, the application objects concerned are removed from the interface and from the database. The figure below illustrates the feature key organization and the settings of the Feature and Security properties.

The ledger series is an example of the feature key organization.

 Columbus IT Partner Russia, ApS

54

Navision Axapta

The feature keys are hierarchical: Default and Extended are children of the feature key and Options and Dependencies are children of Default.

As the feature keys structure is hierarchical, a feature key may be a child of (a child of a child of ...) a child of one of the four standard keys mentioned above. And a key may have more than one parent. The ANDParents property is relevant for feature keys that have more than one parent.

3.9. Backup of Application Objects Using the application object export import facilities Use Axapta’s application object export-import facilities for backup purposes, or if you want to re-use objects from one Axapta installation at another one.

A typical export-import workflow for selected application objects could be 1. Open the Application Object Tree. 2. Select the objects you want to export.



To ease the process of exporting objects of different types, create a project with the objects you want to exportThen select individual objects in the project or export the entire project. If you choose to export the entire project, the individual objects as well as the project with all objects are exported.

3. Choose Export on the Command menu, or on the Application Object Tree shortcut menu. 4. Make the export file available at the Axapta installation where you want to use the application objects, for example on a network drive or on a disk. 5. Open the Application Object Tree at the Axapta installation where you want to import application objects. 6. Choose Import on the Command menu, or click the import icon in the toolbar. 7. Locate the import file and open it. The objects in the export file are presented in a tree structure where you can select all or only some objects. 55

 Columbus IT Partner Russia, ApS

Navision Axapta

Export application objects 1. Open the Application Object Tree and select the objects you want to export. 2. Choose Export on the Command menu. 3. In the Export dialog, select the application object layer checkbox if you want to export from another layer than the current one. Selecting the layer checkbox enables the list with all layers.



You can always see the current layer in the status barIf you want to export an entire application layer, make sure that the current node is the AOT root node and then select the relevant layer.

Use the Browse button to find a location and a name for the export file. The file name list holds the five most recently used .xpo file names. The extension for an export file is .xpo. 4. Click Export to perform the export with the selected options.

Import application objects 1. Open the Application Object Tree. 2. Choose Import on the Command menu. 3. In the Import dialog, use the Browse button to locate the file to import and open it. The file name list holds the five most recently used export file names. The objects in the export file are presented in a tree structure.

Pic. 3-22 Initially all objects in the tree are selected for import. To de-select individual objects, expand the branches in the tree and clear the checkbox next to the object you want to exclude from the import. The names of objects that already exist in the Application Object Tree appear in bold in the import tree. The AOT shortcut menu is available in the import dialog. Particularly the Compare command is helpful in deciding whether you want import a particular application object.



All commands in the shortcut menu are performed on objects in the Application Object Tree. For example, if you use Find and replace or Replace source, you are doing the replace in the AOT.

4. Click OK to perform the import with the selected options.  Columbus IT Partner Russia, ApS

56

Navision Axapta When you click OK, a warning appears if one or more objects already exist in the Application Object Tree. You can choose to evaluate each individual object, or click Yes to all/No to all.

Delete table and class members This check box only has effect for application objects of types table and class. For other application object types, the check box is always implicitly selected and they are always overwritten. When the check box is not selected, the import overwrites existing members. If the application object in the AOT has more members, for example additional methods, these methods are untouched. When the check box is selected, the import overwrites existing members AND deletes members in the AOT that are not present in the import file. The overwrite check box had effect for these member types: For tables

Fields Field Groups Indexes Relations Methods

For classes



Methods You always import objects into the current application object layer.

A note about exporting tables and classes During export and import, tables and classes are handled differently than other application object. When you export a table or a class, only the members (fields, field groups, indexes, relations, and methods) that have been created or modified in the layer you are exporting from are included in the export. When you later import such objects, you should make sure that the Delete table and class members check box is not selected. As opposed to tables and classes, application objects like forms, reports, and queries are always fully exported. This means that for example all methods, controls and so on are exported, whether or not they have been created or modified in the current layer.

3.10. Tips Setting development options The Options... command on the Tools menu opens a dialog where you can set various system options. One of the tab pages in particular, the Development tab page, is useful during the development process. To view the development options 1.

Click Options... on the Tools menu.

2.

Click the Development tab.

General Startup project

Load this project on startup.

Application object layer

Use the Application object layers list to define layer view on objects in the

57

 Columbus IT Partner Russia, ApS

Navision Axapta tree. Show no layers No objects are labeled with layer indications. Show all layers All objects are labeled with layer indications for all layers in which they exist. Show highest layer All objects are labeled with layer indication for the highest layer. Show corrected layers Only objects that have been modified in the current layer or a higher one are labeled and only with indication for the highest layer. Show all from corrected layers Only objects that have been modified in the current layer or a higher one are labeled but with indication for all layers. Message limit

Number of lines in the message window. When this limit is reached, the lines are discarded. To view the discarded lines, you can examine the object’s log file in the system’s main directory. Log files are called comp.log, for example Bankcomp.log for the log file resulting from a compile of the object called BankAccountReconcile. These log files are temporary and the file names are not unique. The log file in the above example is overwritten when you next compile an object called, for example, BankDepositSlip.

Cross reference

Select this if you want the system to update X-reference data automatically when you compile. Selecting the Cross-reference box invariably slows down compilation. On the other hand, you will always have updated information when you want to use the cross-reference system or the Application Hierarcy Tree utility.

Development warnings

Select this if you want developer warnings during X++ code translation. A warning is given if, for example, SQL statements exist that will most probably result in inferior performance. The SQL statements below result in a warning if a key on the table myTable with the fields myField1 and myField2 does not exist: select * from myTable where myTable.myField1==x && myTable.myField2==y;

AOT Log

Have information during import, export, and compile written to a log file.

Debug Show debug information

Check this if you want the debugger to show the debug information window.

The debug information window is the small window in the lower right corner and the debug stack window is the one in the lower left corner that shows the  Columbus IT Partner Russia, ApS

58

Navision Axapta call stack. Show debug stack

Check this if you want the debugger to show the debug stack.

Debug mode

Use the Debug mode list to define when the debugger is activated. No The debugger is never activated. Always The debugger is activated X++ code when is executed. On Breakpoint The debugger is activated when a breakpoint in the X++ code is encountered.

Editor Overwrite selected text

Check this if you want typing to replace selection in the X++ editor.

IntelliSense

Check this if you want to use automatic IntelliSense features in the X++ editor.

Insert at cursor

Enable insert mode (as opposed to overwrite mode) in the editor.

Auto Auto-update

Enter the number of seconds the system should wait before initiating a new update cycle. Entering 0 disables the system’s update cycle. An update cycle comprises three types of updates: •

Auto-refresh



Auto-save

• Garbage collection When you have given an interval here, you can enable or disable the three options individually. Auto-refresh

Check this if you want the system to update application objects automatically so that objects made by other users become available to all users. In addition, the system updates lock indications in the Application Object Tree. You can also refresh manually using the Refresh command in the shortcut menu on for example the Forms or the Queries nodes. Note Refresh is one of the three components in an update cycle, and is performed only when an update cycle interval is given (the Auto-Update option).

Auto-save

Check this if you want the system to save application objects automatically. When the Auto-Save option is enabled, the system automatically saves unsaved objects when you exit. Note Automatic save is one of the three components in an update cycle, and is performed only when an update cycle interval is given (the Auto-Update option).

Garbage collection limit

Number of application objects no longer in use. MorphX automatically performs garbage collection when the number given here is reached. The system uses memory each time an application object is opened in the Application Object Tree. Unless a value is given here, application objects are never discarded from memory. Note Garbage collection is one of the three components in an update cycle, and is performed only when an update cycle interval is given (the Auto-Update option).

59

 Columbus IT Partner Russia, ApS

Navision Axapta Best Practices Click Check Best Practices on the AOT shortcut menu to perform checks according to the below selections. General check

Various checks (for example for the use of the AutoDeclaration property) not covered by the specialized checks listed below.

Check AOS

For optimal AOS performance, hints are given on setting methods and classes to run on client or on server. Note The hints given here are based on a static analysis and consequently they may not tell the whole truth about AOS performance. AOS hints should only be implemented after careful evaluation using the best of your knowledge of the dynamics of application execution. To learn more about AOS hints, refer to Developer's Guide books "Axapta Object Server: How it Works" and "Axapta Object Server: Best Practices for Application Development"

Check label use

User interface texts are implemented using labels, for example @SYS23660 rather than "Auto update". Text constants in single quotes in X++ code should be system related text that does not appear on the user interface. Consequently it is not required that they are implemented using labels.

Check AOT path

Each path in the Application Object Tree is unique. This means that all subnode for a given node must be named differently.

Trace Database trace

Select this if you want the system to trace to the message window whenever the database is accessed.

Method trace

Select this if you want the system to trace to the message window whenever a method is activated.

Client-Server trace

Select this if you want to include information about where classes are executed.

ActiveX trace

Select this to enable tracing of ActiveX control events. This means that all events fired by the ActiveX controls are logged in the message window. Different ActiveX controls fire different events, but most ActiveX controls share a common set of events, such as MouseMove, MouseDown, MouseUp, KeyDown, KeyUp, etc.

Property sheet Sort alphabetically

Select this option to have properties sorted alphabetically when displayed in the property editor.

Easing your login procedure When you start Axapta, the first dialog that appears is the Logon dialog:

Pic. 3-23

 Columbus IT Partner Russia, ApS

60

Navision Axapta Because Axapta supports unified login, you can bypass this dialog and have Axapta depend on your operating system login name and authorization check.

To make Axapta use your operating system’s integrated security 1. Click Options on the Tools menu. 2. On the General tab page you can see the name you have used to logon and possibly your full name. 3. Enter your operating system name in the field labeled OsAccountName.

Pic. 3-24 The next time Danny Jansen starts Axapta, it will check whether he exists as a user and since he does, he never sees the logon dialog.

Modifying other users The User setup dialog above gives you access to modifying your own setup only. If your have administrator permissions in Axapta, though, you also have access to other users’ accounts and to create and modify user information. To simplify other users’ login procedure by making Axapta depend on their operating system account names, use the Administrator menu. 1. Double-click Users on the Administrator menu.

61

 Columbus IT Partner Russia, ApS

Navision Axapta

Pic. 3-25 2. Make sure that you have given the operating system user name in the User dialog.

Pic. 3-26 In the example above the user, Peter Smith, has given his operating system account name as peter. When Peter Smith next starts Axapta, it will check whether he exists as a user and since he does, he never sees the logon dialog.

Using Windows Regional Settings Windows Regional Settings are read when the Axapta system is started. Axapta uses the settings listed below.

Number settings Country code Decimal symbol (decimal separator) No. of digits after decimal Digit grouping symbol (1000 separator) Negative number format Display leading zeros

Time settings Time separator (':','/',' ' or '.') AM/PM or 24 hours  Columbus IT Partner Russia, ApS

62

Navision Axapta

Date settings Short date style Date separator ('/','-' or '.')



Reports run on the server uses the client's regional settings.

How do I locate… When you have opened a form from the Main menu, use the Setup command on the form's shortcut menu to locate various kinds of information about the form. 1. Right-click a form to open the shortcut menu.

Pic. 3-27 2. Click Setup to open the User setup form.

Pic. 3-28 Use the Information tab and the Add-Ins button to locate various types of information about the form.



For each control the Permissions section displays the name of the feature key used as well as the access. Click More info... to display the Feature key permissions tab on the Users dialog. This

Locate the name of an application object 1. Click the Information tab in the User setup dialog to view the form name.

63

 Columbus IT Partner Russia, ApS

Navision Axapta

Pic. 3-29 2. Using the name, you can now locate the form in the Application Object Tree yourself.

Locate the form in the AOT and open it in a seperate widow 1. Click the Fields tab in the User setup dialog. 2. Click the Add-Ins button, point to Open new window and then click Open application object window. The form is now opened in a window of its own.

Locate the label ID for a container control 1. Click the Fields tab in the User setup dialog. 2. Select the container control in the tree structure. 3. Click the Add-Ins button and then click Properties. The property sheet for the control is now opened. Properties can be viewed for other types of controls as well but typically their label is inherited from and Extended Data Type and consequently not immediately visible from the control's properties.

Locate the name of a field behind a control 1. Click the Fields tab in the User setup dialog. 2. Select the container control in the tree structure. 3. Click the Add-Ins button and then click Properties. The property sheet for the control is now opened. The DataField and DataSource properties display information about the underlying data source.

Add company logo to the Main menu When the Main menu opens, it displays the name of the license holder and the installation's serial number. The information is obtained from the License information dialog and shown also in the About box. To add your company logo in bitmap On the server, place a bitmap file called "companylogo.bmp" in the application folder's \share\include directory.

Executing commands on startup When Axapta starts, the startup methods on the fundamental application classes Application (appl. startup()) and Info (info.startup()) are called. Use this if you need to have a command executed on startup.  Columbus IT Partner Russia, ApS

64

Navision Axapta



The startup methods are used for vital system and version specific calls, and you should never modify them directly. Serious consequences may follow if the SYS layer versions of the methods are not called.

Instead, use the SysStartupCmd class framework available for this specific purpose. Calls on startup are executed in this sequence: appl.startup() //here the SysStartupCmd class is instantated sysStartupCmd.applInit() super() sysStartupCmd.applRun() info.startup() sysStartupCmd.infoInit() super() sysStartupCmd.infoRun()

Execute a command on startup 1. Create a class that extends the SysStartupCmd class to perform your specific task. Example: In the standard application the class SysStartupCmdBuildNoSet is used to set the build number. Use a similar approach for your task. 2. Modify the construct method on the SysStartupCmd class so that your class is called. Example: /* code lines left out here */ switch (s) { case 'SetBuildNo': return new SysStartupCmdBuildNoSet(s,parm); case 'UpdateBuildNo': return new SysStartupCmdBuildNoUpdate(s,parm); } /* code lines left out here */ 3. If you need to add parameters to commands executed on startup, add them to the Startup command field on the General tab in the Axapta configuration utility. Example: In this example, the application build number wil be set to 493 when Axapta starts. Instead of giving the command from the Axapta Configuration Utility, you may choose to use the command line parameter -startupcmd=.

65

 Columbus IT Partner Russia, ApS

Navision Axapta

4. Working with MorphX Development Tools The Application Object Tree constitutes your normal view of the application object database when working in Axapta’s integrated development environment. In additions to the AOT, however, MorphX includes a number of tools that offer alternative views on the object database.

Pic. 4-1 Using the various tools you can customize your view of application obejcts to suit your current work situation and thus facilitate the development process. The MorphX development tools are: Name

Use the tool to...

Application Hierarchy Tree

Use the Application Hierarchy Tree tool to improve your overview of how your classes, tables, and Extended Data Types are inherited. The objects are presented in a hierarchical tree structure that enables you to see how objects extend each other.

Application management

Use the Application management tool to record the developers responsible for the individual application objects. Click the Update command on the Tools submenu to generate your own updated application management list.

Application object

Use the Application object tool to generate an alternative view of the objects in the Application Object Tree.

Count of application objects

Use Count of application objects to count application objects and code lines on the different methods in the Application Object Tree.

Cross-reference

Use the Cross-reference system to see the connection between variable names, type names and application paths. The cross-reference system gives you direct access to modify X++ code.

Last choice

Use Last choice to get an overview of the most recent database updates. Last choice lists manipulations that were made through a query or through a job execution.

Locked application objects

Use Locked application objects to have an overview of all application objects that are currently locked. You can also use the dialog to remove a lock.

Number of records

Use Number of records to make the system count the number of records in each table in the current company.

Report Wizard

Use the Report Wizard to help you create a report. The wizard takes you through the necessary steps and offers to save the report in the Application Object Tree.

 Columbus IT Partner Russia, ApS

66

Navision Axapta Table Definitions

Use Table Definitions to generate a report presenting an overview of selected tables. The overview includes fields, types, labels, feature keys, and help texts.

Visual MorphXplorer

Use the Visual MorphXplorer to visualize the relationship between tables and classes by drawing Entity Relation Diagrams.

To access the tools click the General tab on the application’s main menu and then expand the Development menu. Alternatively, you can click the Development submenu on the system’s Tools menu. Many of the tools are also available on the Add-Ins submenu on the AOT shortcut menu. When activated from the Add-Ins submenu the tools take the current node as point of departure. Typically a tool like for example Application Hierarchy Tree would be activated with a specific node as its point of departure.

4.1. Using the Cross-Reference system The Axapta cross-reference system was designed to improve your overview of application objects. The cross-reference system can answer questions like • Where is a field accessed (read/written)? • Where is a method activated from? • What are the type names used in the system? • What are the variable names used in the system? Cross-references are based on what happens in the X++ code, on labels, and on information in the property sheets. The latter comprises information about the use of tables, fields, indexes, Extended Data Types and Base Enums. To be able to use cross-references you must make the system generate the necessary information first.

Create a cross-reference system Creating a cross-reference system for your application is very easy! You just click Update Periodic on the Cross-reference submenu. The Cross-reference submenu is located on the Development submenu on the Tools menu. In the update dialog you can check

This means that...

Delete all

All previously generated cross-reference information is deleted.

Update all

The complete cross-reference update starts. This is how you should first generate your cross-reference system. Note This is a time-consuming process as the entire application is re-compiled and approximately 500,000 records are updated.

Selective

Selected information only is updated. Use the Select button to enter range and sorting criteria for the information that must be updated. When you click Select, a dialog is opened where you can choose which application objects you wish to generate cross-references for. Tip You will normally update selectively when you have made modifications to your application.

67

 Columbus IT Partner Russia, ApS

Navision Axapta Update data model

Cross-reference information used by the MorphXplorer is updated. Tip If you want to update only what is strictly necessary to use the MorphXplorer, click the Select button and make a select on a non-existent object, for example Record Type ”Displaytool” and Name ”z” (click the Advanced button in the query form to see Name).

Update type hierachy

Cross-reference information used by the MorphXplorer and the Application Hierarcy Tree is updated.

You can use the Batch button in combination with any of these selections. When you click Batch a dialog is opened where you give batch parameters, for example start date and start time. You will normally use Batch to ensure that periodic updates are undertaken when the system is not heavily loaded.

Having the system update cross-references automatically If you do not want to manage periodic updates yourself, you can choose to have the cross-references updated automatically 1. Click Options on the Tools menu. 2. Click the Development tab and check the XReferences box.



This means that whenever you make modifications, save and compile then your crossreferences are updated automatically. This will increase the save and compile time somewhat.

Using the cross-reference system When you have generated your cross-reference information, the system provides three ways to access it Names When you click Names the system provides a list of application objects with name, type, and number of references in the cross-reference system.

Pic. 4-2 Application object

Name

Type name

The object’s type, for example ”Extended Type”, ”Table”, or ”Class”.

The name of the application object.

The name of the application object type. If the ”Type name” field is empty, the entry is a reference to an application object defined in the

 Columbus IT Partner Russia, ApS

68

Navision Axapta tree. In the illustration above, there is an application object named ”ZipCode” of the ”Table” type in the tree. If the ”Type name” field is not empty, the entry is a reference to something defined on a type or declared of a type. The type is listed in the Type name field. Examples: A variable will have its variable name in the name field and its type in the Type name field. A field will have its name in the name field and its table name (it's type) in the Type name field A static method in a class will have its name in the name field and its class name in the Type name field Clicking the References button opens a list of references with paths in the Application Object Tree.

Pic. 4-3 The list shows actions on the selected object: The variable is declared, read, written in the Construct method of the InventABC class, and it is declared in the InventABCUpdate class. Path When you click Path the system provides an overview of paths in the Application Object Tree. In the window you can see: • The path in the Application Object Tree. • The date and time of the most recent cross-reference update. • The id of the user who performed the cross-reference update. • The number entries in the cross-reference system (”References”). • Whether the object is still valid. Deleted objects are not automatically removed in the crossreference system. Click the Delete all Non Valid button to remove them. You can use the information to see where objects are used in the X++ code. The References button lists each entry in the cross-reference system. The illustration below lists the 8 references to \Classes\AVI\Length and provides an overview of what happens in the X++ code. The Edit button opens the X++ editor to allow you to modify your selection. The illustration below shows the editor when the line \Classes\AVI\Length was double-clicked. The deleteAllNonValid button automatically removes all objects with the Valid box unchecked. 69

 Columbus IT Partner Russia, ApS

Navision Axapta

4.2. Generating an Application Hierachy Tree To generate an application hierarchy tree:

1. Point to the Tools menu, then the Development submenu and click Application Hierarchy Tree.

Pic. 4-4 The left pane displays the object types available in hierarchy view. The right pane is empty until an object in the left pane is selected. When you expand one of the nodes, information about the the current node is displayed in the right pane. The nature of the information displayed depends on the type of the node.



For classes and tables particularly, the most beneficial way to access hierarchy information is to activate Application Hierarchy Tree from the Add-Ins submenu on the AOT shortcut menu. The selected class or table is then the point of departure for the tree.

The illustration below is an example of three levels of inheritance hierarchy on a string type.

Pic. 4-5 Right-click a node in the hierarchy tree to open a shortcut menu. Use the Search command to have a complete one-level list of the selected object type rather than a hierarchical view.

Application Hierarchy Tree information What object types are you looking for information about? Application Heerachy Tree information for tables For tables information about methods, fields and indexes is displayed.

 Columbus IT Partner Russia, ApS

70

Navision Axapta

Pic. 4-6 A static method is indicated with preceeding double colons, for example ::CreditMax. A mandatory field (the Mandatory property on the field has been set to Yes) is marked with an asterisk (*). A unique index (the AllowDuplicates property on the index has been set to No) is marked with two asterisks (**).



As the Application Hierarchy Tree is available for system tables as well, use it to view system table indexes. System tables are marked with a red padlock symbol in the Application Hierarchy Tree.

Application Hierarchy Tree information for classes The first column lists the methods on the selected class. The following columns list the superclass methods that have been overridden within the subclass.

Pic. 4-7



The same information, though without method information, can be created and displayed graphically using the Visual MorphXplorer.

A static method is indicated with preceeding double colons, for example ::ValidateAccount. The Application Hierarchy Tree is available for both system and application classes. System classes are marked with a red padlock symbol in the Application Hierarchy Tree. Right-click a class in the Application Hierarchy Tree to open a shortcut menu. The commands Compile forward and Compile backward are particularly useful. Compile forward

compiles the current class and all its children.

Compile backward

traverses the tree to the parent of the current class and compiles the root parent and its children down to and including the current class.

71

 Columbus IT Partner Russia, ApS

Navision Axapta Use Show X-ref on the shortcut menu to switch to viewing cross-reference information. The toggle-facility is useful for locating variables, for example with the purpose of ensuring that they have been named consistently. Application Hierarchy Tree information for data types For all types, the Label and the HelpText properties are inherited so this is the information provided by the Application Hierarchy Tree.

Pic. 4-8



The Search on the shortcut menu is particularly useful for types. Use it to have a complete one-level list of types rather than a hierarchical view.

The Add-Ins submenu is also available on the shortcut menu. Use for example the cross-reference system's Used by command to explore where a particular data type is being used.

If information for a hierarchical view is not available... When you activate Application Hierarchy Tree you may be presented with a message like this one.

Pic. 4-9 The message indicates that the system does not have sufficient information to present the tree. To generate this information you must update the cross-reference system. 1. Point to the Tools menu, the Development submenu, then Cross-reference, and click Update on the Periodic submenu. 2. Make sure that Update type hierarchy is checked and click OK.

4.3. Using the MorphXplorer You use the MorphXplorer to visualize the Axapta data model by drawing Entity Relation Diagrams. You can depict the relations between tables with this information: • The current table’s 1:n relations. • The current table’s n:1 relations. • The classes that use the current table. • The maps that the current table is a part of.

 Columbus IT Partner Russia, ApS

72

Navision Axapta

Pic. 4-10 You can also depict relations between classes.

Pic. 4-11 In a class visualization diagram you can depict: • What classes the current class uses. • What classes the current class is being used by. • The current class’ super class. • The current class’ sub classes. All commands for visualization are available on the current object’s shortcut menu. Using the General and Colors tabs, you can give any diagram a title and define your own color setup.

Creating a tables relation diagram 1. Click the General tab in the Main menu, then expand the Development node and double-click MorphXplorer. Alternatively you can open the Explorer from the Development submenu in the Tools menu. 2. Right-click anywhere in the dialog to open a shortcut menu and click Table in the New submenu. 3. Double-click the name of the table you want to see relations for. A rectangle representing the table appears. Click at the position where you want to place the visualization of the table. A rectangle with rounded corners represents the table.

Pic. 4-12

73

 Columbus IT Partner Russia, ApS

Navision Axapta The rectangle is labeled with the name of the table, the table label, the table id, and the company (or the virtual company) that the table belongs to in your current setup.



If the textual information is difficult to read, use the Zoom command on the shortcut menu.

4. Right-click the table rectangle to open a shortcut menu and click n:1 or 1:n on the Relations submenu. Clicking n:1 opens a list of tables that the current table has a many-to-one relationship to. The list gives the name of the table and the name of the relation. If the relationship is expressed by a relation explicitly defined on the table, the relation name is preceded by a plus sign, for example '+BankAccountTable'. Typically, the relation consists of more than one field. If the relationship is expressed by a relation explicitly defined on the table, and it is a Field fixed conditional relation, the relation name are surrounded by parenthesizes, for example '+(Bank)'. Typically, it is an optional relation. If the relationship is expressed through an Extended Data Type, the name of the field is given. Examples: The Address table has a many-to-one relationship to the CompanyInfo table. This is defined by the CompanyData relationship on the Address table. The Address table also has a many-to-one relationship to the Country table. This is defined by the Extended Data Type on the Country field in the Address table. Clicking 1:n opens a list of tables that the current table has a one-to-many relationship to. The list gives the name of the related table and the name of the relation. For the example above, the Address table, the 1:n submenu has no entries. However, when the current table is CustTable, one of the entries in the list is CustTrans, AccountNum. This means that the CustTable table has a one-to-many relationship with the CustTrans table expressed by the Extended Data Type on the AccountNum field.



If the list of relations is empty this may be because you have not generated cross-reference information that the Visual MorphXplorer depends on.

5. Select a table in one of the lists and click anywhere in the MorphXplorer window. The symbol for the table is positioned where you click and the relation is automatically drawn as a line between the two tables. Repeat steps 4 and 5 for each new table you want to add to the MorphXplorer diagram.



You can join two identical objects by positioning them on top of each other.

Include class and map information in a table relations diagram When you have created a table relations diagram, you can include information about the classes that use the current table and information about the maps that the current table is a part of.

To include classes information 1. Right-click a table in a tables relation diagram 2. In the shortcut menu, click Used by in the Composition submenu. 3. Select a class and position it.

To include maps information  Columbus IT Partner Russia, ApS

74

Navision Axapta 1. Right-click a table in a tables relation diagram 2. In the shortcut menu, click Maps in the Generalization submenu. 3. Select a map and position it.

Pic. 4-13

Creating a classes diagram 1. Click the General tab in the Main menu, then expand the Development node and double-click MorphXplorer. Alternatively you can open the Explorer from the Development submenu in the Tools menu. 2. Right-click anywhere in the dialog to open a shortcut menu and click Class in the New submenu. 3. Double-click the name of the class you want to investigate. A rectangle representing the class appears. Click at the position where you want to place the visualization of the class.

Pic. 4-14 The rectangle is labeled with the name of the class, an indication of where the class is, and the class id. 4. Right-click the class rectangle to open a shortcut menu and click Using or Used by in the Composition submenu. Clicking Using opens a list of classes that the current class uses. Clicking Used by opens a list of classes and tables that use the current class.



If the list of classes is empty this may be because you have not generated cross-reference information that the MorphXplorer depends on.

5. Select a class in one of the lists and click anywhere in the MorphXplorer window. The symbol for the class is positioned where you click and the relation is automatically drawn as a line between the two classes. Repeat steps 4 and 5 for each new class you want to add to the class diagram.



You can melt two identical objects by positioning them on top of each other.

Including super and sub classes information in a class diagram When you have created a class diagram, you can include information about the sub classes of the current class and about which is the current class’ super class. 75

 Columbus IT Partner Russia, ApS

Navision Axapta 1. Right-click a class in a class diagram 2. In the shortcut menu, click Super Class or Sub Classes in the Generalization submenu. Note that there is only one super class while there may be a number of sub classes. 3. Select a class and position it.

Opening, saving, and printing diagrams from the MorphXplorer To open a diagram in the MorphXplorer 1. Right-click anywhere in the MorphXplorer window. 2. Click Load in the shortcut menu. 3. Select the Varchart project file (*.vcn) you want to open and click Open.

To save a diagram in the MorphXplorer 1. Right-click anywhere in the MorphXplorer window. 2. Click Save in the shortcut menu. 3. Enter a name for your diagram and click Save. You may also choose an existing file and overwrite it.

To print a diagram from the MorphXplorer 1. Click the print button in the toolbar. 2. Click Print to start printing the diagram. The MorphXplorer printing environment also allows you to • Scroll with the Next and Previous buttons. • Show as single or multiple pages with the Single button. • Define your page layout with the Page layout button. • Set up your printer with the Printer setup button.

Arranging, zooming, and copying in the MorphXplorer To arrange a diagram from the MorphXplorer 1. Right-click anywhere in the MorphXplorer window. 2. Click Arrange in the shortcut menu. All tables, classes, and relations are now re-arranged according to a best-fit algorithm.



The Arrange cannot be undone.

To zoom from the MorphXplorer 1. Right-click anywhere in the MorphXplorer window. 2. Click Zoom in the shortcut menu and select the zoom factor you want.

To copy from the MorphXplorer 1. Right-click anywhere in the MorphXplorer window. 2. Click Copy to clipboard in the shortcut menu. The diagram is now copied to the clipboard and you can paste it into the application you are currently working in, for example Microsoft Word.  Columbus IT Partner Russia, ApS

76

Navision Axapta

Legend in the MorphXplorer The Visual MorphXplorer uses Unified Modeling Language (UML) notation.

Tables

Classes

4.4. Other Tools Using the application objects list To generate a view of application objects on a list format 1. On the Tools menu, point to the Development submenu, then the Application objects submenu, and click Application objects.

Pic. 4-15 77

 Columbus IT Partner Russia, ApS

Navision Axapta Typically you will use the list view for search purposes. The list view displays one line for each application object. Use the Filter command on the shortcut menu to filter on for example a specific user or a type of application object. For each application object, this Information is available: UtilLevel

The application object layer that the object was created and saved in (sys, syp, dis, dip, and so on)

RecordType

The application object type.

Name

The name of the application object as you can see it in the Application Object Tree and in X++ code.

Type name

If the record type is a method, this column gives the name of the class or table that the method is a member of.

Modified by

The user who last modified the object.

Modified date

The date the object was last modified.

Modified time

The time the object was last modified.

Use the tabs to view general details, created and modified information and version control information.

Using the buttons in the dialog Edit

When the current line in the application list identifies a method, you can use the Edit button to open the X++ editor and modify the code directly.

Application management

Use Application management to handle application object review. With the Approve button in the Application management dialog you can stamp date and time information as well as your user id on the object.

Cross-reference

Use the Names or Path commands to see where the object is referenced. If you do not get the expected result, this may be because you have not generated the necessary cross-reference information.

Document handling

Use Document handling to open Axapta’s document handling system. The dialog lists the document references and corresponding notes attached to the selected record in the active form. You can choose between viewing all references or only those references typed by the current user. The dialog box allows you to:

Add-ins



Show notes



Create notes



Show documents



Create new documents



Edit existing documents



Print existing documents



Link existing document references to other references

Use the Add-ins button to access the commands in the Add-ins menu with specific reference to the object on the current line in the application object list, for example Compare or Find and replace.

 Columbus IT Partner Russia, ApS

78

Navision Axapta

4.5. Creating Wizards A wizard is a special form of user assistance that automates a task through a dialog with the user. Wizards help the user accomplish tasks that can be complex and require experience. Wizards can automate almost any task, such as creating a new report, facilitating data import, or defining access rights. They are especially useful for complex or infrequent tasks that the user may have difficulty learning or doing, or for tiresome, often performed tasks. A wizard is a series of presentations or pages that helps the user through a task. The pages include controls that you define to gather input from the user; that input is then used to complete the task for the user. Examples of standard Axapta wizards are: • The Report Wizard that leads you through the steps of creating a report. The Report Wizard simplifies the report generation process in that the user is led through the steps necessary for creating a report. The wizard, though, does only what the user can do himself if he chooses to use the commands in the Report node’s shortcut menu. The Report Wizard is available from the Tools menu (choose Development, then Wizards and then click Report Wizard). • The Setup Wizard that guides you through setting up Axapta. The Setup Wizard ensures that you go through the large number of steps required to set up Axapta – in exactly the right sequence. The Setup Wizard starts automatically the first time you start Axapta. To help you create your own wizards with the same look and feel as the standards ones, Axapta includes a Wizard Wizard. Like the Report Wizard, the Wizard Wizard is available from the Tools menu. When you activate the Wizard Wizard, you open a wizard with some steps where you define the contents of the steps the user will go through in the resulting wizard. Step 1

A welcome dialog where you just click Next to continue. In the finished wizard you should use this page to describe the results of using the Wizard.

Step 2

In the naming dialog you must give the name of the wizard. You can choose the first part of the name freely must end in 'Wizard', for example SysTableAccessWizard. The objects (a private project, a class, a form, and a menu item) that are created as a result of the wizard-generation are automatically given identical names.

Step 3

In the type selection dialog you must choose which type of wizard you want to create. The choice will decide the context in which the wizard will appear. You can choose between •

a default wizard



a default data wizard, and



a feature key wizard.

Step 4

In the setup dialog you must choose the number of steps in the resulting wizard. However, you can add or remove pages later.

Step 5

In the last dialog you must click Finish to have the system generate the wizard.

The result of running the Wizard Wizard is the creation of a private project with three objects, a form, a class, and a menu item. To make the wizard perform the desired task, you must now modify the form and class objects. If the wizard is of standard type, you may also want to insert the menu item in a suitable menu.

79

 Columbus IT Partner Russia, ApS

Navision Axapta



Use the Application Hierarchy Tree facility to get a list of all wizards in Axapta. 1. Open the Application Object Tree and select the SysWizard class. 2. Right-click to open the shortcut menu, point to Add-Ins, and select Application Hierarchy Tree.

Create a wizard 1. From the Tools menu, choose Development, then Wizards and click Wizard Wizard. 2. Click Next in the wizard wizard’s step one, the Welcome dialog. 3. Enter a name for the wizard in the wizard wizard’s step two, the naming dialog. Wizard naming: You must enter the wizard name in the top most field. The name must end in ”Wizard”, for example ”MyReportWizard”, ”MyFormWizard”. The fields below the Axapta object names heading are for information purposes only and cannot be modified. They are the names of the objects that are created automatically by the Wizard Wizard. To enable the Next button, click one of these fields. 4. Choose wizard type in the Wizard Wizard’s step three and click Next. The available wizard types are: • Standard wizard, • Default data wizard, and • Feature key wizard. A standard wizard is used to help the user perform general tasks. The Report Wizard is an example of a standard wizard. A default data wizard is used to help the user create necessary default data like address information and number sequences. All default data wizards are automatically included in the system’s Default Data Wizard and its status, whether it has been executed or not, is indicated. The Default Data Wizard can be started from the Axapta Setup Wizard that is automatically activated when you first start Axapta, and from the Company accounts menu. A feature key wizard is used to help the user set up feature keys. All feature key wizards are automatically included in the system’s Feature Key Wizard and its status, whether it has been executed or not, is indicated. The Feature Key Wizard can be started from the Axapta Setup Wizard that is automatically activated. 5. Choose number of steps required in the Wizard Wizard’s step four and click Next. This is the number steps that the Wizard Wizard creates automatically. You can always change the number of steps later simply by adding or removing a new tab page to the wizard form. The number of steps include the Welcome and the Finish dialogs. 6. Click Finish to complete the wizard generation. The result of running the Wizard Wizard is the creation of a private project with three objects: a menu item, a form, and a class. The objects have the name you entered in the Wizard Wizard’s naming dialog.

To complete the wizard • Give the wizard a title. Do this by modifying the Caption property on the Design node, or by using the description() method.

 Columbus IT Partner Russia, ApS

80

Navision Axapta • Give each step, except the first and the last ones, a title and an explanatory text. Do this by modifying the Caption and HelpText properties on each tab page control. • Add a description of the results of using the wizard to the first tab page. Do this by adding a StaticText control to the tab page. • Add a description of the results of clicking the Finish button to the last tab page. • Add functionality (methods) to the wizard class. • Add visual layout to the wizard by modifying the wizard form. All multi line texts should be created as StringEdit controls. Recommended property settings AutoDeclaration

Yes

AllowEdit

No

Width

Column width

Height

Column height

Skip

Yes

Border

None

MultiLine

Yes

BackgroundColor

Button face (3D)

ShowLabel

No

• Make your wizard available from a menu using the wizard's menu itemNote



If you choose to run your wizard from the Application Object Tree, you should run the class and not the form.

Guidelines for wizard development The guidelines below are general Microsoft development guidelines available on http://msdn.microsoft.com that have been slightly modified to suit Axapta. • Model your Wizard after the ones that ship with Windows 2000 and Office 2000. • Always include a statement of purpose for the wizard on the first page and include a graphic on the left side of the page. The purpose of this graphic is to establish a reference point, or theme, such as a conceptual rendering, a snapshot of the area of the display that will be affected, or a preview of the result. You can continue to include a graphic on the interior pages for consistency or, if space is critical, use the entire width of the window to display instructional text and controls that require user input. • Minimize the number of pages that require the display of a secondary window. Novice users are often confused by the additional complexity of secondary windows. • Avoid a wizard design that requires a user to leave the wizard to complete a task. Lessexperienced users rely heavily on wizards. Asking the user to leave a wizard to perform a task can lead to confusion. Instead, design your wizard so that the user can do everything from within it. • Make it visually clear that the user interface elements in a graphic illustration on a wizard page are not interactive. You can do this by varying elements from their normal sizes or rendering them more abstractly. • Include default values or settings for all controls where possible. • Avoid advancing pages automatically. The user may not be able to read the information before a page advances. In addition, wizards are intended to allow the user to be in control of the process that the wizard automates. 81

 Columbus IT Partner Russia, ApS

Navision Axapta • Display a wizard window so that the user can recognize it as the primary point of input. For example, if you display a wizard from a control that the user chooses in a secondary window, you may need to position the wizard window so that it partially obscures that secondary window. • Make sure that the design alternatives offered by your wizard provide the user with positive results. You can use the context, such as the selection, to determine which options are reasonable to provide. • Make sure that it is obvious how the user can proceed when the wizard has been completed. This can be accomplished in the text on the last page of the wizard.

The wizard class Depending on the type of wizard you chose, your wizard class extends either the SysWizard class, the SysBaseDataWizard class, or the SysFeaturekeyWizard class.

Useful methods on the SysWizard class boolean validate()

This method is called before the wizard is closed. Return false if the user input is invalid. This will prevent the run() method from being called when the user clicks the Finish button. The method is used to validate user input.

FormRun formRun()

Returns a formRun which is an instance of the form of the same name as the class. This method is always overridden but should not be changed.

static void main(args args)

Creates a new instance of the wizard and calls wizard.run on the SysWizard class. This method is always overridden but should not be changed.

void run()

This method is called when the user clicks the Finish button – if validate() returned true.

void setupNavigation()

Use this method to set up whether the Next and Back buttons should be enabled from the start. Default is that all is enabled, except back in the first step and next in the last. The buttons can then be enabled runtime when a certain condition is fulfilled.

Useful methods on the SysBaseDataWizard class boolean Enabled()

Determines whether the wizard should be displayed in the list of basic setup wizards.

boolean MustRun()

Determines whether the base data already there or whether the wizard should create it.

str Description()

Returns a short description of what the wizard does. The description is used in the wizard’s caption if the Caption property has not been set.

Useful methods on the SysFeaturekeyWizard class FeatureKey featureKey()

Determines which feature key, along with the feature key’s children, the wizard sets up. This method MUST return a valid feature key. If the feature key has been disabled, the wizard will not appear in the Feature Key Wizard (SysFeaturekeyWizard). Note Feature keys that have the Security property set to Yes cannot be disabled.

 Columbus IT Partner Russia, ApS

82

Navision Axapta Such keys can be disabled as part of the user group administration only. The system class variable featurekeySet should reflect the user’s choice. The FeatureKeySet system class has the method boolean enabled(featureKey p1 [, boolean enable] ) to enable/disable the feature key.

The wizard form The wizard form has one tab and the number of tab pages you specified as steps in the Wizard Wizard. The following methods are available on the form: FormTabControl tab()

Returns the tab

classDeclaration()

Holds a variable named like your wizard of type sysWizard. In the run() method on the form the variable will be assigned to the wizard’s class.

On your own wizard controls Do not set the Left property to Left edge, and Do not set the Top property to Top edge. These settings do not conform with the Axapta wizard standard. Most frequently you should let the controls have Auto settings. The first and the last tab pages The first and the last tab pages have identical layout. These pages must only have controls where you can set the background color to white. The controls automatically have their color set to white and the AllowEdit property set to Yes. The middle tab pages The middle tab pages have identical layout. On these pages, the Caption and the HelpText properties are used. The Caption property is used as heading and the HelpText property is used as an explanatory text.

Pic. 4-16 All tab pages If the Visible property has been set to false, the tab page is skipped. If the Feature property has been set and the user does not have delete rights, the tab page is also skipped. This can be used to control the flow of the wizard.

Wizard tips Enable a button depending on user input When the user goes through wizard steps, you will occasionally need to make sure that he has entered the proper input before he is allowed to go on. In practical terms this means that the Next button should not be enabled until the user has entered the necessary information. Example: Input dependent button enable 83

 Columbus IT Partner Russia, ApS

Navision Axapta This is used in the Database Log Wizard. On the Domains tab page, the user must select which domain he wants to register database changes for. He is not allowed to continue until he has actually made a selection.

Pic. 4-17 When you create a wizard using the Wizard Wizard, one of the methods that exists on your wizard class is called setupNavigation. This method used to set up the initial states of the Back and Next buttons on your wizard. Example: Enable Back and Next buttons On the SysDatabaseLogWizard, the setupNavigation method looks like this: void setupNavigation() { nextEnabled[2] = false; } The single statement disables the Next button on the second tab page. The test to discover whether the user has entered the required information and the Next button enabling is performed on the relevant form control method. Example: Testing user input For the SysDatabaseLogWizard the relevant form control is the ListView control that displays the list of companies: int mouseDown(int x, int y, int button, boolean ctrl, boolean shift) { //statements missing .... { // statement missing ....  Columbus IT Partner Russia, ApS

84

Navision Axapta sysWizard.nextEnabled(true); } return ret; } Another example: On the SysWizardWizard form is another example of enabling the Next button. On the Naming tab page, the user must enter a wizard name that ends in "wizard" before the Next button is enabled. The code to test whether this condition has been fulfilled is located on the StringEdit control's textChange method: #define.nameTab(2) void textChange() { super(); // statements missing... { if (!sysWizard.isNextEnabled()) { sysWizard.nextEnabled(true, sysWizard.curTab(), false); } } else { if (sysWizard.isNextEnabled()) sysWizard.nextEnabled(false, sysWizard.curTab(), false); } } Two things are interesting here: • The use of isNextEnabled() to test whether the Next button has been enabled, and • The two additional parameters to nextEnabled. The second parameter (sysWizard.nextEnabled(false, sysWizard.curTab(), false);) is the tab page where the Next button should be enabled. This parameter is optional and the default is the current tab page. The third parameter (sysWizard.nextEnabled(false, sysWizard.curTab(), false);) indicates whether focus should be moved to the Next button. This parameter is optional and the default is true.

Control wizard flow - skipping a tab page To control the wizard flow by skipping a tab page when certain conditions are fulfilled, use the skipTab method available when your wizard is based on the SysWizard class. Example: Skip a tab page On the Account use tab page in the LedgerTableWizard, the user specifies what the account is to be used for. Based on the selection, one of the following tab pages concerning sales tax is skipped. boolean modified() { 85

 Columbus IT Partner Russia, ApS

Navision Axapta boolean ret; #DEFINE.TaxPage(8); ret = super(); ledgerAccountUse = this.selection(); if (ledgerTable.AccountPlType >= LedgerAccountType::AccountOperations && ledgerTable.AccountPlType form data source -> table. If AllowEdit has been set to No in one of these, the user is not allowed to make any modifications. Fixed vs. dynamic forms When the form size is static, the Size and Maximize commands in the form’s system menu are disabled. The form size is static when one of the size properties (Left, Top, Width, and Height) is not set to Auto. AutoDataGroup and DataGroup  Columbus IT Partner Russia, ApS

176

Navision Axapta When a data group on a form has AutoDataGroup set to Yes • Fields within the group cannot be moved, • Fields within the group cannot be deleted, nor can new fields be added, • Fields within the group cannot have their properties changed, and as a consequence the property sheet is grayed, • Methods on the fields cannot be overridden.



Setting AutoDataGroup to Yes is strongly recommended for performance reasons, particularly when running in a three-tier environment.

When AutoDataGroup has been set to Yes, the individual fields on the form are not saved but are read from the underlying table. This means that the form is loaded and displayed much faster. Because that fields are read from the table, fields are displayed in the sequence they appear in the table. ButtonDisplay and related properties The ButtonDisplay property is related to these other properties: • Text • NormalImage • NormalResource • DisabledImage • DisabledResource

Description of properties for a form data source Property

Use this property to ...

Rules and hints

Name

change the name of the data source.

Axapta standard The name is merely used for display purposes. However, if you would like to change the name, you should do so on the database table.

AllowCheck

allow that the permissions on table level are checked.

Axapta standard Should normally be set to Yes, but this is no fixed rule. You should deliberate what is appropriate for your application.

AllowCreate

allow new records to be created in the data source.

Axapta standard Must normally be set to Yes, but this is no fixed rule. You should deliberate what is appropriate for your application.

AllowDelete

allow deletions in the data source

Axapta standard Must normally be set to Yes, but this is no fixed rule. You should deliberate what is appropriate for your application.

AllowEdit

allow modifications to the data source

Axapta standard Must normally be set to Yes, but this is no fixed rule. You should deliberate what is appropriate for your application. Tip You can set the AllowEdit property for the whole form here but to let you to prohibit

177

 Columbus IT Partner Russia, ApS

Navision Axapta modifications for individual fields, the same property exists on each field in the data source. AutoNotify

allow notification upon change of record.

Axapta standard Must be set to Yes. Part of Axapta’s AutoJoin system

AutoQuery

have the system automatically generate a query for the data source that joins it with the data source given by the JoinSource property.

Axapta standard Must be set to Yes. Part of Axapta’s AutoJoin system.

AutoSearch

have the system automatically perform a search on the data source.

Axapta standard Must be set to Yes. Part of Axapta’s AutoJoin system.

Company

change the level to which the table data belongs

CounterField

use one of the database fields as counter in the form. The field must be of type Real.

Tip A CounterField is typically used to ensure that a record inserted in a form is given a line number that corresponds to the actual, sequential position in the form. For example, if a new line is inserted between lines 3 and 4, the new line is given line number 3,5. This is used for example in the CustWorksh in the standard application. To achieve this effect the field given as CounterField should be given as index on the database table.

DelayActive

delay the execution of the data source’s Active method.

Axapta standard Must be set to Yes. Part of Axapta’s AutoJoin system. Tip This property is particular useful when two data sources are linked (when the LinkType property is Delayed). Setting the property to Yes means that the data sources Active method is not activated until after a certain delay (20 milliseconds). This is to handle the situation when the user presses the down arrow to scroll in a list on his data source.

Index

use one of the indexes defined on the table specifying that you want data from the table sorted according to that index.

InsertAtEnd

create a new record when the user moves the cursor past the last record in the table (for example by pressing F8).

InsertIfEmpty

have the system insert an empty record ready for entering data if it finds no records in the table. If InsertIfEmpty is set to No, the user must create a new record himself (for example by pressing CTRL+N)

 Columbus IT Partner Russia, ApS

178

Navision Axapta JoinSource

have the system join two data sources.

This property is set only when two or more tables are used as data source and you would like to join them.

LinkType

have the system maintain an active link between two data sources and research the second table when focus in the first one changes.

Axapta standard Must be set to Delayed. Part of Axapta’s AutoJoin system. Tip This means that when you have a one-to-many relationship between two tables, scrolling in one automatically updates the other. An example of this is a customer table and a table of transactions for each customer. With LinkType set to Active, scrolling from one customer to the next also automatically updates the transaction list to display transactions for the current customer. Setting the property to Delayed means that updating a linked data source is not performed until after a certain delay (100 milliseconds). This means that if the user presses the down arrow to scroll in a list on his data source, the linked data source is updated for the last record only (the record the user finally focuses on). When you set the LinkType property to Delayed, the linked data source may not be refreshed immediately after the super() call in the Active method on the master form.

OnlyFetchActive

select fields on controls in the form.

This property is designed to be used in lookup forms. There is no code in these forms, and they will open faster because the result set is smaller. When OnlyFetchActive has been set to Yes, records cannot be deleted from within the form. This is to preserve data integrity by ensuring that delete is never attempted on incomplete records. Should the user attempt to delete a record, an error message is issued.

StartPosition

define whether the first or the last record should be the current one upon startup.

Axapta standard Unless your form is used for postings, the StartPosition property should be set to First.

Table

use data from this table.

Axapta standard For clarity, the Name and Table properties should be identical.

Description of properties for form design Practically all properties on the form Design node also exist on the individual controls, for example the Width and Height properties. However, when you set a property on the Design node - as opposed to setting it on a control - the setting affects the entire form. A few properties exist only on the Design node. They are described below. Property 179

Modify this property to...

Rules and hints  Columbus IT Partner Russia, ApS

Navision Axapta Frame

modify the frame used for the form.

Axapta standard Normally the Frame type is Standard. The other types do not have a caption and are typically used when a new form is opened from within a form (for example, when a form is opened when the user clicks a lookup button).

HideToolbar

hide form specific buttons on the toolbar.

The property is intended for forms that are not tied to the database.

Mode

set the data entry mode for the form.

setCompany

have the system change company when the form gets focus.

TitleDataSource

choose the data source to be used in the form caption.

WindowResize

allow form re-size.

WindowType

specify the window type.

The form title consists of the TitleDataSource property followed by the string generated by the table’s caption method, for example Customers (Customer Account: 6743245) When the user is creates a new record, the caption will be Customers ()

Joining data sources on forms To display related fields from different tables, you can join or link two data sources.

Joining data sources To display fields from different tables intermixed within the same grid control, you can join two or more data sources in a form. Compared to using edit and display modifiers to have field values displayed in a grid control, joining data sources gives far superior performance. Also, joining data sources allow selects, inserts and updates simultaneously in more than one table since it only uses one query. Navigation is performed within the query and the active() method is fired on both the master and child data source when the selection changes. The property used to define the type of join is called LinkType. To join a child data source to a master data source, set the JoinSource property to the master dataset and the LinkType to InnerJoin, OuterJoin, ExistJoin, or NotExistJoin.

Linking data sources If you pass a data source from one form to another, for example using the DataSource property on a menu item buttons, you create a link between the master data source and the child data source on the other form. The same behavior can be obtained in one form by setting the JoinSource property on the child data source, and setting the LinkType on the child data source to Active, Passive or Delayed. Updates of linked child data source in relation to the parent data source is controlled by setting LinkType to Passive, Delayed, or Active on the parent data source. Since a linked child data source may itself be a master data source in another relation, Passive, Delayed, and Active property settings determines how data sources linked to the child data source are updated. Example of parent and child data sources are orders and order lines. When the user selects a new order, the list of order lines must be updated accordingly.  Columbus IT Partner Russia, ApS

180

Navision Axapta JoinSource and LinkType properties When data sources are linked on a form or between forms, the behavior is controlled by the JoinSource and Link Type properties. The figure below illustrates how their settings interact:

Pic. 6-5 When the user changes record in the parent data source, the active() method is called. When the method is called is controlled by the DelayActive property. DelayActive can be Passive, Delayed, or Active. The super() call in the active() method on the parent data source calls the linkActive() method on all linked child data sources. How and when this is performed is controlled by the LinkType property on the parent data source. LinkType can be Passive, Delayed or Active. If the property LinkType is InnerJoin, OuterJoin, ExistJoin or NotExistJoin the child data source is joined with the parent data source. In this case the linkActive() method on the child data source is not called as the joined data sources are considered to be one data source.

Name

How the join is performed

Passive

Linked child data sources are not updated automatically. Updates of the child data source must be programmed on the active() method of the master data source.

Delayed

A pause is inserted before linked child data sources are updated. This allows for faster navigation in the parent data source since the records from child data sources are not updated immediately. For example, the user could be scrolling past several orders without immediately seeing the order lines for each one.

Active

The child data source is updated immediately when a new record in the parent data source is selected. Notice that continuous updates are resource-consuming.

InnerJoin

Selects records from the main table that have matching records in the joined table – and vice versa. In other words, you get one record for each match and records without related records are eliminated from the result.

OuterJoin

Selects records from the main table whether or not they have matching records in the joined table.

ExistJoin

Selects a record from the main table for each matching record in the joined table. The difference between InnerJoin and ExistJoin: When the join type is ExistJoin, no more potentially matching records are searched for once the first match has been found. When the join type is InnerJoin, all matching records are searched for.

NotExistJoin

Select records from the main table that do not have a match in the joined table.

181

 Columbus IT Partner Russia, ApS

Navision Axapta



Use the form tutorial tutorial_Join to see the different results produced when you change the LinkType property.

Join data sources 1. Set up the relationship between the tables to be joined. This can be done either on the tables or on the Extended Data Type of the field(-s) to be joined. 2. On the form, set the JoinSource property of the child data source to the data source you want to join with. 3. Set the LinkType property on the child data source. If you are linking the data sources you should also set the LinkType property on the parent data source. This is not mandatory but recommended since it makes it easier to see what you want to accomplish. 4. Create the form design and display the relevant fields from the form data sources. Typically you would choose a grid control for your joined data sources. Designing the layout of a form When designing the layout of a form where a table is used as the underlying data source, use a drag-anddrop operation to move a group, or individual fields from the pool of groups and fields in the form's Data Sources node to the form's Design node. On the basis of the field's data type the system automatically selects the control best suited to represent the field. A StringEdit control is selected for a text type, an IntEdit control for an integer type, a RealEdit control for a real type, a DateEdit control for a date type and a ComboBox for an enumerated type. You will also see that a lot of properties have the value Auto. These properties are typically inherited from the underlying field. To see a description of the available controls, click

.

At any stage in the development process, you can see what the form looks like by clicking Compile and then Open in the shortcut menu on the form. Note that when you move a group, the group remains a group in the layout, and can be given its own heading. Normally, the system's auto-selections are adequate; however, if you would like to modify any of the default properties that define name, position, color, margin etc., click the property sheet icon . You can also modify the form layout by clicking Edit in the shortcut menu on the Design node. This opens the form in design mode soyou can size the individual controls manually. Note, however, that you are not allowed to size bound controls with Auto properties. For example, if a field has the Width and Height properties set to Auto, then you cannot modify the size of the control. The form editor is advantageous because you can follow the system's sizing and positioning of each control, and correct any undesired positioning or size immediately. Groups are dynamic... Note that when you move whole groups as they were defined in the underlying table data source from the Data Sources node to the Design node, the groups are dynamic. This means that whatever you do on the underlying table (add or remove a field from the group) is automatically reflected on the form. On the other hand, you cannot simply delete a control from a group. If you do so, the control automatically re-appears. More methods...  Columbus IT Partner Russia, ApS

182

Navision Axapta When you move a group or a single field to the Design node, the system automatically creates the necessary methods to detect, for example, mouse movements, check focus, and validate. Also more advanced facilities... Moving a group of fields or a single field to the Design node to create a form is the most basic way to design a very simple form. The system also provides facilities to create forms with the following: • • • •

Multiple tabs, Group headings, Buttons to activate functions, menu commands and other forms and reports, Lines and pictures.

One data source Joined data sources are treated like one data source. This means that • selects, • updates, and • creates from forms are performed on both/all tables. Methods that operate on the data source, like next, executeQuery and so on, are redirected to the data source that owns the join, the main data source. Init is run for both/all data sources. Notification methods like active are run for both/all data sources.

6.3. Designing Forms Determining the opening view of a form The DataSource property defines the table from which you see data from when you open a form. Browsing the properties of a form's Design node you will see the DataSource property in several places both on containers like Design, Tab, TabPage and Group and on individual controls (like StringEdit, IntEdit etc.) Data source is given on containers to define in which table to scroll when the user changes to next or previous record (using F7 or F8). The system first checks the container for a data source: if the container has a data source, the system changes record in the table indicated here. If the container does not have a data source, the data source on the control is used. The DataSource property is only set automatically by the system when individual fields are moved from the Data Source. Several controls with different data sources may be located in the same group or on the same tab page and in such cases the data source on the container indicates the table to scroll in. The sequence in which the individual records in the underlying table are shown is set up by the indexes defined on the table. Generally the query system selects the index best suited to the task in hand. However, if you find that the query system uses another one than you would like, or if there are two, equally suited indexes, you can set the Index property on the form data source. If using an index does not suffice... When records are retrieved for display in a form, the mechanism that handles the retrieval process is a query that the system automatically generates. The indexes defined are used in this auto query. If you

183

 Columbus IT Partner Russia, ApS

Navision Axapta would like another sorting sequence than the one defined by the index (for example descending rather than ascending), one way to obtain this is to modify the auto query from your X++ code.

Specify whether a form opens for modification and data entry When you create a form you can specify what actions the user is allowed to perform on the data in the underlying table. You restrict access through the following properties on the form data source: Property

The property's function

AllowEdit

Allow modifications to the data source

AllowCreate

Allow new records to be created in the data source

AllowDelete

Allow deletions in the data source

Implicit forms variable declarations Normally you need to declare variables before you can use them. Working with forms, though, some variables are implicitly declared by the system. A variable named like the form data source to reference the table, for example MyTable. This enables you to 1. Call a method defined on the table used as underlying data source for the form, for example MyTable.SetDefault(ReadWrite::Write);

2. Reference the individual fields on the table, for example A_No = MyTable.AccountNo;

A variable named like the form data source postfixed with _ds to reference properties and methods on the form's data source, for example MyTable_ds. This gives you direct access to invoking the methods in the FormDataSource system class, for example MyTable_ds.ReSearch();



If you wish to call for example ValidateWrite, which exists on both the form data source and on the table, you must use the _ds variable (for example MyTable_ds.ValidateWrite) to activate the method on the data source.

A variable called element to reference the whole form object Element is typically used in assignments like the one shown here. NotifyDate = Element.Design().Control(Control:: NotifyDate);

Validate or restrict data in forms There are many different ways to restrict or validate data in forms. The most obvious way is to create controls that by their nature limit the values that can be entered. For example, you can create a check box that accepts only Yes/No values or a list box that requires you to pick from a list of previously entered values. You can also limit or restrict data entry by setting control properties and form properties. In most cases, you will want to use the AllowEdit, AllowCreate and AllowDelete on the form data source. This way, you only have to set the properties once.  Columbus IT Partner Russia, ApS

184

Navision Axapta Any bound control that you create inherits properties set for the field in the table. If the controls on your form are unbound, however, you may want to set properties in the form controls. In the large majority of cases, you can validate or restrict data using properties that you set on the table or on the form. In certain cases, however, you may need to create your own methods for additional power and flexibility. For example, you may want to display different error messages for different types of errors in a field, or you may want to verify that any two of three fields are filled in before saving a record.

Order of evaluation for controls and fields The calling sequence when data is modified through a control on a form is top down: first the methods on the control are evaluated, then the methods on the data source, and finally the methods on the table. This means that when a control is exited the following methods are activated: Method

On the...

Comments

Leave

form control

Here you can only use the property system to get the value. The method is always activated when you leave a control.

Validate

form control

Here you can only use the property system to get the value. The method is activated only if the user has edited the contents of a control.

Modified

form control

Following the call to super() the value in table field has been set. Modified is activated in the following situations: When an edit field (one of the following controls: StringEdit, IntEdit, RealEdit, DateEdit or TimeEdit) is exited. When a selection in either CheckBox, RadioButton, ComboBox or Listbox is changed. The method is activated only if the user has edited the contents of a control.

Validate

form data source

The value in table field has been given its new value. The method is activated only if the user has edited the contents of a control.

ValidateField

table

The method is activated only if the user has edited the contents of a control.

Modified

form data source

The method is activated only if the user has edited the contents of a control.

If any of the validate functions returns false then the field is not given a new value.

Auto-arrange principles in forms To ensure a uniform application interface, all properties have sensible Auto values. The aim is that a form can be created using a drag-and-drop operation, setting only very few properties manually. It is highly recommended to take advantage of the automatic setting of properties. Occasionally, though, the system’s Auto property values may not suit the current situation and therefor it may be helpful to understand the auto-arrange principles in forms. When the system generates a form based on property settings, this is done in three phases 1. Size: the form size is determined. 2. Position: the position of the individual controls is determined. 3. Alignment: the controls are aligned.

185

 Columbus IT Partner Russia, ApS

Navision Axapta

Phase 1: Size The size of a control is defined as the size of the control itself plus the control label. The sample form below shows 5 groups (in different colors) that each has one or more controls. The fact that the size of a control is the control plus the label becomes important when the system begins the alignment phase.

Pic. 6-6 The Width and Height properties define the dimensions of the control and the corresponding ones for the label (LabelHeight and LabelWidth) define the label. The Auto settings here make allowances for preferences with respect to font, font style, font size etc. in that the dimensions simply change dynamically when for example a larger font size is selected.

Phase 2: Position Container controls (Tab, TabPage, and Group) are arranged in one or more columns as specified by the Columns property on the parent control. In the above example, the five groups are arranged in two columns. Whether the groups should be arranged in columns or in rows is defined by the ArrangeMethod property. In the example the method is horizontal. Regardless of the preferred method, the first column (row) always has the higher priority. In the example three groups have been placed in the first column, and two in the second. The VerticalSpacing property defined the space (in pixels) after the control. In the example below the VerticalSpacing spacing property for Group1 (the gray group) has been changed from Auto to 40.

Pic. 6-7 The overall purpose of the Top and Left properties is to allow you to reserve space (for example for a button or a group of buttons) relative to another form. Use the Top property to glue the control to the top edge or the bottom edge, and the Left property to align to the left or the right edge. In the example below the Top property for the green group has been set to Top edge, and the Left property to Right edge. Also, the AlignChild property on the group has been set to No.

 Columbus IT Partner Russia, ApS

186

Navision Axapta

Pic. 6-8 The general rule is that the more edges a control is tied to (for example both the top and the right edge), the more space is reserved. Rather that select one of the predefined values in the system, you can choose to give coordinates in the Top and Left properties. A control where you have entered coordinates has higher priority during the form’s arrange phase than one with Auto properties.

Phase 3: Alignment The three central alignment properties are: AlignChildren

for container controls

When set to Yes, the control aligns the controls it can see, its immediate children. In the example above, the children of the form are the five groups and the children of the gray group control are the controls named “Label Label Label” and “Label”.

AlignChild

for container controls

When set to Yes, the control accepts to be part of the alignment defined by the parent control. Setting the property to No indicates that the control is not to be included in the alignment that is performed by the parent control (the container control).

AlignControl

for individual controls

When set to Yes, the control accepts to be part of the alignment defined by the parent control. Setting the property to No indicates that the control is not to be included in the alignment that is performed by the parent control (the container control)

In the example below, in the second control (called “Label”) the AlignControl property has been set to No, and in the second group (the yellow one) the AlignChild property has been set to No.

Pic. 6-9

187

 Columbus IT Partner Russia, ApS

Navision Axapta

Sizeable forms Sizeable forms can be dynamically sized by the user to display more information than was originally displayed. Typically information heavy forms like forms with grids or several tab pages are sizeable. The majority of Axapta forms are sizeable. The fact that a form is sizeable is indicated by the lines in the form's lower right corner. Forms that will not display more information if made larger should not be made sizeable. The Currency form on the General ledger menu is an example of this type of form. Whether a form is sizable or not is determined by the settings of the Height and Width properties on the individual controls. When set to Column height and Column width respectively, the form can be sized. Note, though, that for controls to be sizeable, the container control (group, tab, tap page etc.) that holds them must also be sizeable. During form resizing, the controls on the form are resized to fit the new form size. Controls positioned in several columns share the additional height when a form is made larger. However, they do not share additional width: the last column gets any extra width.



Properties cannot be changed for a control in a group that has the AutoDataGroup property set to Yes.

See the tutorial_arrange form for an illustration of the possible combinations of Height and Width settings on various controls.

Toggling between different views on data As an example of a situation where X++ code is used on a form control, consider the situation where we have two forms based on data sources with a one-to-many relationship between them. An example of this could be the customer records and the customer postings. For each customer, there may be any number of postings of which some or all may be settled. To be able to toggle between viewing all postings and viewing open (unsettled) postings only, you modify one of the control methods. The CustTable and CustTrans forms from the standard application are examples of forms with the one-tomany relationship described above. In the CustTrans form there is a CheckBox control to toggle between viewing all or viewing open postings only.

Pic. 6-10 When the user checks the box labeled “Show open only”, the system should do a research in the data source. Consequently the Clicked method has been modified.

 Columbus IT Partner Russia, ApS

188

Navision Axapta

Pic. 6-11 CustTrans

is the implicitly declared variable used to reference the table data source

ds

is short for '(form) data source' and references the FormDataSource system class

ExecuteQuery

is the method in the FormDataSource system class that executes the query automatically generated by the system

Display a message box When you want to display a brief, modal message, use the application class Box. The Box methods correspond to the different values of the system enum dialogBoxType: Dialog type

Enum value/method names

When to use the Box methods

Information dialog

infoBox

The user should be informed of something, and must click OK.

Warning dialog

warnBox

The user should be warned of something, and must click OK.

Yes/No dialog

yesNoBox

The user is given a choice where he must click Yes or No.

Stop dialog

stopBox

The application has stopped, possibly beacause some error happened, or something serious is going to happen, and the user must click OK.

Yes/No/Cancel dialog

yesNoCancelBox

The user is given a choice where he must click Yes, No, or Cancel.

When you implement Box:: you should • Choose the box method appropriate to the situation. • Use the return value (of type DialogButton) for situations that require the user to make a choice (the Yes/No dialog, the Yes/No/Cancel dialog, and the Ok/Cancel dialog) • Define a default button (of type DialogButton) when you use more than one button (for the dialog types mentioned above) • Write a text that the user can understand. • Define a suitable caption. • Write a suitable help text. Examples Box::warning("@SYS53167', "@SYS18245')

189

 Columbus IT Partner Russia, ApS

Navision Axapta (box::yesno(strfmt("@SYS24509", ledgerJournalTrans.paymentReference), "@SYS24283", "@SYS29058") == DialogButton::Yes)



DialogButton::Yes,

The application class Box makes use of the system class DialogBox. However, you should not call DialogBox directly, but always use Box as an indirection.

Using display and edit method modifiers Display is a method modifier used to indicate that the method’s return value is to be displayed on a form or a report. The return value is typically a calculated value, for example a sum. Only methods with a return value can be modified by display. You can use the display modifier on methods in five different places: • On table methods • On form methods • On form data source methods • On report methods • On report design methods Write your display methods on a table because in this way you can use the same code in several forms or reports if you want.

Define a display method To define a display method, give the display keyword right before the method’s return type, for example: display Amount Amount() which is a method on the CustTrans table. The exception to this is when you define display on a form data source method. If you choose to write a display method on a form data source, you must include the data source as parameter, for example display InventQty Accumulated(InventBudgetInvent Budget) which is a method on the data source for the InventBudgetInvent form.



You must use display on a form data source method when the return value is to be shown on a grid control.

A display method is called each time the form is re-drawn and consequently a display method should never hold calculations more complex and time consuming than what corresponds to one direct lookup in the database. A display (or an edit) method is not activated if it is on a hidden tab page.

Use a display method on a form or a report Once you have created the method, use it on a control shown on a form or a report. The way in which you do that is identical no matter where you have chosen to write your display method. Note Identical control and method return types are required.

 Columbus IT Partner Russia, ApS

190

Navision Axapta This means that if, for example, you have a RealEdit control on your form, the display method you are using must return a value of type real. The Amount method mentioned above is used on the CustTrans form on the Amount control.

Pic. 6-12 The DataSource property indicates where the method is located, and the DataMethod property gives the name of the method. If the DataSource property is not set, the system assumes that the method has been defined on the form. Looking at a report example, the BalanceCur method is used on the CustTransList report on the BalanceCur control.

Pic. 6-13 The DataMethod property gives the name of the method that has been modified by display. As the Table property has not been set, the system assumes that the method has been defined on the report (on the design or on the report) or possibly in the ReportRun system class where for example page is a display method. When you set the Table property the system looks for the BalaceCur display method (given in the DataMethod property) on the database table. The ExtendedDataType property If the ExtendedDataType property is set, formatting, help text, and so on is taken from the type given here. The ArrayIndex property If the display method returns an array, set ArrayIndex to 0 to indicate that all array elements are to be shown on the report. If, for example, you set it to 2, this indicates that only array element number two is shown. 191

 Columbus IT Partner Russia, ApS

Navision Axapta

Use an edit method on forms The edit modifier is an extension of display so that controls using an edit method can do the following: • Display a value and accept user input The edit modifier can be used on the following: • Table methods • Form methods • Form data source methods The parameter profile, though, is a bit different from that of display methods. This is an example of an edit method on a table: edit FreeTxt TxtDefault(boolean Set, FreeTxt Txt) Both parameters are used when the method is subsequently tied to a control on a form. The boolean parameter Set is true if the user has entered anything in the control The text parameter Txt is used to hold the values that the user has entered in the control The parameter profile for edit used on a form method is identical to the one above for edit used on a table method. When edit is used on a form data source method, the data source must also be included as a parameter, for example edit Amount Settle(boolean set, CustTrans _CustTrans, Amount U) which is a method on the data source for the CustOpenTrans form. The method is used on the Settle control on the form. Like in the above example with the display method, the DataSource and the DataMethod properties must be set on the control.



Like other fields, both edit and display methods may be added to field groups on the underlying table.

Summary of parameter profiles for display and edit Parameters for display

Parameters for edit

table method

none

boolean Set value

form method

none

boolean Set value

form data source method

data source

boolean Set data source value

report method

None

(Not applicable)

report design method

None

(Not applicable)

The standard lookup form: what it consists of The contents of the system’s standard lookup forms are based on relations set up on the database table, and on the Extended Data Type. It consists of these components • TitleField1 from the related table • TitleField2 from the related table • The fields making up the relation

 Columbus IT Partner Russia, ApS

192

Navision Axapta If any of these are identical, the system automatically leaves out duplicates.

An example from the application: the Customer group field on the CustTable form Clicking the lookup button on the Customer group field on the CustTable form’s General tab page give you a list like the following:

Pic. 6-14 The lookup information is based on the relation on the CustGroupId Extended Data Type used for the CustGroup field.

Pic. 6-15 TitleField1 and TitleField2 from the CustGroup table, the related table, are CustGroup and Name.

Pic. 6-16 So the values in the first column are CustGroup field values, and the column heading is the CustGroup field label “Customer group” that is inherited from the Extended Data Type. The values in the second columns are Name field values, and the column heading is the Name field label “Description”, also inherited from the Extended Data Type. The third component, the related field, is omitted as it it identical to TitleField1.

The lookup facility: creating you own lookup forms When you choose to have a lookup button on your control, the Lookup method on your form control is activated when the user clicks the button. The Lookup method displays a standard form but if you want to display another form instead, you can either • Override the Lookup method, or • Create your own custom lookup form, or • Use the AutoLookup field group on the underlying data source.

Overriding the Lookup method on a form control The super() call in Lookup checks whether the control is bound to a field, or to an Extended Data Type and calls either performDBLookup(FieldId,FileId,Company); or performTypeLookup(ExtendedDataType,arrayIndex,Company); 193

 Columbus IT Partner Russia, ApS

Navision Axapta which are both member functions (methods) on the Formcontrolname class (FormStringControl, FormRealControl, FormIntControl, FormDateControl or FormTimeControl). You can override the super() call, and call one or the other method yourself, and give the necessary parameters. One possibility is to call performDBLookup with only FieldId, in which case you can perform a lookup on another field within the same data source. void Lookup() { FormStringControl FEL; FEL = element.design().control(control::Country); //12 is the Id for the field to be shown on the Country control FEL.performDBLookup(12); }

Both methods may also be called with an alternative Company to achieve a lookup in another data file. Default company is the one that the current data source belongs to.



Use the ButtonImage property on the Extended Data Type to choose a suitable image to display next to your field. To learn about the property, click.

Custom lookup Creating the lookup form yourself offers you even greater flexibility. To do this use the method performFormLookup(FormRun); which is also a member function (method) on the FormcontrolnameControl class (FormStringControl, FormRealControl, FormIntControl, FormDateControl or FormTimeControl). When you use this method, you must do more programming yourself but the lookup form may be anything you like. In the form to be used as a lookup form, you must do the following: 1. Set the Frame property to Border. This means that the form will have no caption or size frame. 2. Close the form using the CloseSelect(str) method. CloseSelect is a member function on the FormRun class. As the name indicates, the method closes the form while selecting the string given as parameter. An example The form ColorLookup looks like this Green

Red

Blue

Yellow

It has four buttons in different colors with the names of each color. The idea of using this form as a lookup form is that when the user clicks one of the buttons, the name of the button (the color name) is pasted in the control. Consequently, the Clicked method is overridden for all four controls. Below is the Clicked method for the green button.  Columbus IT Partner Russia, ApS

194

Navision Axapta void Clicked() { Element.CloseSelect("Green"); } In the Lookup method on the control that you want to have a custom lookup, you do the following: void Lookup() { FormRun FR = New FormRun(New Args("ColorLookup")); FR.Init(); this.PerformFormLookup(FR); } where “ColorLookup” is the name of the form displayed upon lookup. Continuing the example from above… When the color lookup form is used, it looks like this:

Pic. 6-17 The Lookup method on the StringEdit control labeled “Color:” has been modified as indicated above.

Details about PerformFormLookup PerformFormLookup calls the SelectMode and SelectTarget methods (also in the FormControlName class) on the form given as argument. These two methods set the form in SelectMode and identify where the value is to be inserted (using the SelectTarget method). Alternatively, you can call SelectMode yourself, passing a control in the lookup form as parameter. The value of the control will be pasted in the target control. In this case you do not have to pass a string as parameter to CloseSelect.

AutoLookup field group Use the AutoLookup field group to customize the lookup form without any programming at all. First, set up the relation for the lookup. Then on the relatede table, add the fields to the AutoLookup field group that are to be added to the lookup. An example: 1. Create a relation on the table used as data source. The relation may also be defined on an Extended

Data

195

 Columbus IT Partner Russia, ApS

Navision Axapta

Type.

Pic. 6-18Creating

a run-time lookup form

A standard lookup form is created through relations on the database table, and on the Extended Data Type. If, however, you need to create a runtime lookup form that looks up other database fields than the ones offered by the standard lookup form, use the application class SysTableLookup and override the lookup method on the relevant form control. How to use the SysTableLookup class 1. Create a new instance of SysTableLookup by giving the tableId to the table you want to have lookup on. sysTableLookup = new SysTableLookup(tableId);

2. Add fields to the gridControl. sysTableLookup.addLookupfield(_fieldId, _returnItem);

_fieldId

The field ID

_returnItem

Whether the field's value is to be returned. Default the first added field.

3. Limit the data selection. sysTableLookup.parmQuery(query);

4. Override the formControl.lookup() and delete super(). FormRun formRun();

 Columbus IT Partner Russia, ApS

196

Navision Axapta void lookup() { ... // super(); this.performFormLookup(sysTableLookup.formRun()); }

A complete example of overriding the lookup method on a form control void lookup() { Query query = new Query(); QueryBuildDataSource queryBuildDataSource; QueryBuildRange queryBuildRange; SysTableLookup sysTableLookup; TableId tableId; FieldId fieldId; ; tableId = tablename2id('myTable'); sysTableLookup.parmTableId(tableId); fieldId = fieldname2id(tableId, 'MyField_1'); sysTableLookup.addLookupfield(fieldId); fieldId = fieldname2id(tableId, 'MyField_2'); sysTableLookup.addLookupfield(fieldId);

queryBuildDataSource = query.addDataSource(tableId); queryBuildDataSource.orderMode(OrderMode::GROUPBY); queryBuildDataSource.addSortField(fieldId));

sysTableLookup.parmQuery(query);

197

 Columbus IT Partner Russia, ApS

Navision Axapta this.performFormLookup(sysTableLookup.formRun()); }

This manner of creating a lookup form is used in the DocuType form in the application. The full path to the modified lookup method is: \Forms\DocuType\Designs\Design\[Tab:Tab]\[TabPage:Overview]\[Grid:Grid]\StringEdit:ActionClassName\ Methods.



The SysTableLookup is limited to making lookups on fields in a table.

Tips

.

Create a new record when the user opens a form To create a new record each time the user opens a form • Call the create method on the form data source, and • Use suitable settings for the data source properties InsertAtEnd (= No) and StartPosition (= First). An example from \Forms\PurchCreateOrder\Methods\run void run() { purchTable_ds.create(); element.modifyForm();

super();

// more code lines }

Drag-and-drop You can duplicate, copy and paste, and drag-and-drop form controls - both within a form and between different forms. If the data source specified on the control you copy is not present on the target form, the DataSource property is left blank. Between forms, drap-and-drop will always perform a copy operation. Within the same form, drag-and-drop performs a move operation. To copy, press the CTRL key on the keyboard while moving the object.

 Columbus IT Partner Russia, ApS

198

Navision Axapta

6.4. Using ActiveX controls When creating an Axapta form, you can benefit from using ActiveX controls. An ActiveX control is a COM object that can be used as a graphical control inside an application. ActiveX controls can be purchased from a large number of vendors. The diversity of functionality is enormous. The software available as ActiveX components spans from simple components such as check and combo boxes, to larger more complex components such as spreadsheets, calendars, Internet browsers, and communication programs. When you install software such as Microsoft Office, or Microsoft Internet Explorer, a large number of COM objects and ActiveX controls are added to your computer. Before a COM object can be used it must be registered in the registry. The installation program normally handles this as part of the installation process.

Adding an ActiveX control to a form Inserting an ActiveX control in a form in Axapta is done using the Application Object Tree, as you would do for any other type of control. 1. Right-click the Design node for the form, and choose New Control from the menu. 2. Choose ActiveX from the sub-menu. The ActiveX Browser appears. The browser displays a list of all the ActiveX controls registered on your machine (according to the registry). 3. Choose the control you want to insert from the list. A good example is the Microsoft Calendar control (part of Microsoft Office).

Pic. 6-19 Now the control is inserted. The next step is to communicate with the control. 4. Right-click the ActiveX control in the Application Object Tree, and start the ActiveX Explorer.

199

 Columbus IT Partner Russia, ApS

Navision Axapta

Pic. 6-20 This displays all the events that can be started by the control, and a list of all the methods that can be executed on the control. The list of methods is read from the object’s Type Library, and gives you information on how to call the methods. The list of events is also retrieved from the object’s Type Library. However before Axapta can handle any of the events that the ActiveX control can start, you need to add event handlers (methods) for them. 5. Do this by selecting the events you want your form to handle, and click the Add Event Handler button. This creates a number of methods. By adding X++ code to these event handler methods, you can control how Axapta reacts to specific events. Most ActiveX controls offer specific ActiveX properties. These can be set from your X++ code. On the Methods tab page of the ActiveX Explorer, you can see the property methods that the ActiveX control offers to modify the properties as well as other ActiveX specific methods. For example, the Microsoft Calendar control offers a Day property method that is used to set and get the day selected in the ActiveX control.

See and set ActiveX properties 1. Open the visual form designer. On the form's Design node, right-click to open a shortcut menu and select Edit, or Double-click the form's Design node.

2. Right-click the ActiveX control and select Properties on the shortcut menu. 3. Click the Custom property's lookup button to access the ActiveX control's properties.

Pic. 6-21  Columbus IT Partner Russia, ApS

200

Navision Axapta

6.5. Forms System Classes The forms system classes are listed in the Classes sub node in the System Documentation node. They are easily recognizable, as they all contain the prefix Form (FormRun, FormStringControl etc.). The forms system classes enable you to manipulate - create, modify or run – forms from your X++ code. You may even modify forms during runtime so that, for example, one or more controls are hidden on a form depending on the user's selections in the preceding form. Generally, forms system classes are closely connected to the node for the individual form, and the three form sub nodes.

From an overall point of view, the forms fall in two categories: form build classes and form run classes. As the names indicate, the build classes are the ones used during the visual creation of a form, while the run classes are used during execution. System class name

Final

Extends

Form

FormObject

yes

FormRun

yes

FormDataObject

Holds

Use it to...

the form name property and methods to add to the three form sub nodes in the Application Object Tree.

create a form from your X++ code rather than by using the Application Object Tree

methods to execute a form.

activate a form from your X++ code

FormObject

FormDesign

yes

the properties on the Design node in the Application Object Tree and methods to create a control.

FormDesignView

yes

the form name property and the methods activated when a control is modified in edit mode (when you have clicked Edit in the Design shortcut menu).

add a control to a form from your X++ code

FormBuildDesign

yes

the properties on the Design node in the Application Object Tree, and methods to add a control.

create the graphical layout of a form from your X++ code

FormObjectSet

yes

the data source name property and methods on a form data source in the Application Object Tree.

FormBuildObjectSet

yes

FormDataSource

yes

FormBuildDataSourc

yes

201

FormObjectSet

the properties and methods on a form data source in the Application Object Tree.

manipulate the data source on a form from your X++ code

FormBuildObje

the properties on a form data

manipulate the

 Columbus IT Partner Russia, ApS

Navision Axapta e

ctSet

FormControl

yes

Form

yes

FormBuild

yes

source in the Application Object Tree.

properties on a form data source from your X++ code

the properties common to all control types and methods to update and exit. FormControl

the properties and methods for the control as seen in the Application Object Tree.

access individual form controls from your X++ code

the properties for the control as seen in the Application Object Tree.

Form control system classes For each control there is a system class called FormcontrolnameControl, for example FormIntControl, FormTabPageControl, and FormCheckBoxControl. A form control system class allows you to manipulate controls from your X++ code, assuming you declared a class variable to set properties, and activate class methods. FormIntControl FInt; // X++ statements missing here FInt.Value(MyTable.sum()); FInt.Update(); //more X++ statements

Constructing a form from your X++ code When you construct a form from your X++ code, you must use the system classes. Your code lines should look similar to the following form = ClassFactory.FormRunClass(new args(“CustTable”)); form.init(); form.run(); ClassFactory is an object of the class xClassFactory that holds the method FormRunClass that returns a new FormRun object. The idea of using this indirection is to make it possible to inherit the FormRun class and override selected methods to change the behavior of the form executor. Subsequently, you can have all forms in the system executed with the new class instead of the ordinary FormRun by supplying the inherited class in the FormRunClass() method. The system constructs all forms activated from the Application Object Tree using the xClassFactory.

An Alternative way to program the form construction form = new formRun(a); form.init(); form.run(); Method

Function

 Columbus IT Partner Russia, ApS

202

Navision Axapta new

The form constructor that loads the form from disk and creates the form object.

init

Creates the form to be displayed on the screen and manages the construction of the data source.

run

Makes the form window appear on the screen and performs a database search for the data to be displayed in the form.

This sequence of execution is handled automatically by the system whenever a form is activated from the Application Object Tree.

Add a picture to a form using a system class Assume that you have created a form with an unbound Window control named CompanyLogo. In this control you want to display the bitmap named Picture.bmp. 1. Declare a variable to hold the result of your computation in the class declaration method on your form. class FormRun extends ObjectRun {

FormWindowControl CompLogo; }

FormWindowControl is a system class that implements all the properties of a Window control along with a number of methods to manipulate the control. 2. In the form’s Init method you write the code that accesses the control named CompanyLogo. void Init() {

super(); CompLogo = element.design().control(control::CompanyLogo); }

The following is an explanation of the code Sets the variable CompLogo to point to the relevant control: element.design()

addresses the design node of the current form

element.design().control

addresses the controls in the design node

element.design().control(control::CompanyLogo)

addresses the control called “CompanyLogo”

3. In the form’s Run method, write the code that sets the value of the property that holds the bitmap name. Use the following example: void Run() {

super(); 203

 Columbus IT Partner Russia, ApS

Navision Axapta CompLogo.ImageName('Picture.bmp'); }

The following is an explanation of the code Sets the ImageName property to Picture.bmp

The bitmap is located in the current directory. The complete path must be given if the file is located elsewhere.

The code is written in the Run method to initialize the bitmap display. 4. To ensure that the image is updated, if you choose to link to another form, the code is also inserted in the LinkActive on the form’s Data Sources node. void LinkActive() {

super(); CompLogo.imageName('Picture.bmp'); }

Accessing the active query on a form When you have set the AutoQuery property on a form data source to Yes, the system automatically generates the query necessary to retrieve data to display in the form. As the result of user input in the form, though, you may want to modify the system generated query to display a different set of data.

To access and modify a system generated query (code examples from the CustTrans form) 1. Declare a variable of the type QueryBuildRange in the class declaration method on your form. class FormRun extends ObjectRun {

QueryBuildRange CriteriaOpen; //additional declarations {

QueryBuildRange is a system class used to specify the search scope of a query. 2. Initialize the variable in the form data source’s Init method. The initialization must be after the super() call which generates the query. void init() {

super(); CriteriaOpen= This.Query().DataSourceNo(1).addRange(fieldnum(CustTrans,Open)); }

 Columbus IT Partner Russia, ApS

204

Navision Axapta Calling after the super() call in init is equivalent to calling before the super() call in the Run method.

The following is an explanation of the code: Sets the variable CriteriaOpen to point to the Open field in the CustTrans table This

is a reference to the current form data source

Query()

is a member method on the form data source used to get a reference to the form’s query. An instance of the Query system class is always available (see comment above about the AutoQuery property on the form data source) on a form data source as the class is automatically instantiated when the form is opened.

DataSourceNo(1)

is a method on the Query class used to identify the data source that takes an integer as parameter to identify the data source. The first data source is number 1. Returns a QueryBuildDataSource MorphX object.

AddRange

is a method on the QueryBuildDataSource class used to add a search range to the active criteria. It takes a field id as parameter and returns a QueryBuildRange.

FieldNum(CustTrans, Open)

is a built-in function that returns the field id, in this case of the Open field in the CustTrans table.



This is the way to get a reference to the active query in order to add a range. The only values that vary are the parameters to DataSourceNo and to fieldnum.

3. Modify the form data source ExecuteQuery method that is activated when the form is opened for data display. The method must be modified prior to the super() call. In the example below, the switch statement performs a test on the variable IncludeAll. Depending on the value of the member variable Value, the QueryBuildRange variable is set to 1 or 0..1. The query can now be executed. void executeQuery() { switch (IncludeAll.Value()) { case (1) : { CriteriaOpen.Value('1'); //see the class declaration: //CriteriaOpen is a variable of type QueryBuildRange break;

205

 Columbus IT Partner Russia, ApS

Navision Axapta } case (0) : { CriteriaOpen.Value('0..1'); break; } } super(); }

6.6. Events on forms An event is a specific action that occurs on or with a certain object. Axapta can respond to a variety of events: mouse clicks, changes in data, forms opening or closing, and many others. Events are usually the result of user action. By adding your own code to one of the system’s methods or by creating methods of your own, you can add your own custom response to an event that occurs on a form. However, in order to know where to add your code, or where to call a method of your own, it is necessary to understand the nature of the methods’ super() calls, and the order of events that occur during common form operations such as

Opening a form: sequence of events When you open a form the following sequence of events occurs:

Pic. 6-22 1. The new constructor on the form is activated. 2. The init method on the form is activated. 3. The init method on the form data source is activated. 4. The run method on the form is activated. 5. The executeQuery method on the form data source is activated. 6. The firstField method on the form is activated.

Closing a form: sequence of events When you close a form by clicking a Cancel button, the following sequence of events occurs:

Pic. 6-23 1. The closeCancel method on the form is activated.  Columbus IT Partner Russia, ApS

206

Navision Axapta 2. The canClose method on the form is activated. 3. The close method on the form is activated. When a form is closed with CloseCancel, user modifications are not saved. When you close a form by clicking the close button or an OK button, the following sequence of events occurs:

Pic. 6-24 1. If the form is closed with an OK button, the closeOK method on the form is executed. closeOK is not activated if a close button is used to close the form.

Leaving a control: sequence of events When a control is exited, the sequence of events occurs:

Pic. 6-25 1. The leave method on the control is executed. 2. The validate method on the control is executed. 3. The validate method on the data source is executed. 4. The validateField method on the table is executed. 5. The modified method on the control is executed. 6. The modified method on the data source is executed

Leaving a record: sequence of events When a record is exited, the following sequence of events occurs:

Pic. 6-26 1. The validateWrite method on the data source is executed. 2. The write method on the data source is executed. 3. The insert (if it is a new record), or the update (if it is an existing record) method on the table is executed.

Deleting a record: sequence of events When you delete a record from a form, the following sequence of events occurs: 207

 Columbus IT Partner Russia, ApS

Navision Axapta

Pic. 6-27 1. delete on the data source is executed. 2. validateDelete on the data source is executed. If validateDelete returns true ... 3. validateDelete on the table is executed. If validateDelete returns true... 4. The record is then re-read from the database by the kernel. Unless the record is deleted or updated by another user, then... 5. delete on the table is executed.

Creating a record: sequence of events When you create a record from a form, the following sequence of events occurs:

Pic. 6-28 1. create on the data source is executed. 2. initValue on the data source is executed. 3. initValue on the table is executed.

Methods on a form When you click New on the Forms shortcut menu to make a new form, a Methods node is automatically created. The purpose of the Methods node is to allow you to add logic to individual forms.



Whenever possible, you should write your code on the underlying table. Methods written on a table are available on any form that uses that table as the data basis. In terms of re-use and inheritance, the Methods node is only the 'second best' place to add code.

The node holds what is called virtual methods which are methods implemented in MorphX, but which you can override to change the form's default behavior. In these methods the function call 'super()' results in the activation of MorphX's implementation of the method. As the name indicates, classDeclaration is the declaration of a class, namely the class FormRun. In the classDeclaration you define the variables you are going to use in X++ code written on the form, i.e. the scope of any variable defined here is the form's Data Sources, and the form's Designs nodes. Method name

Is executed when...

Comments

canClose

the form is closed

The super() call checks whether it is a valid action to close the form. canClose is activated by closeCancel and by closeOK. Use this method to add your own checks to the system’s close verifications.

Close

the form is closed

The super() call closes the form window, manages database updates, and sets the boolean flag closed. Depending on the close state of the form, close is activated either by closeCancel, or by closeOK.

closeCancel

the user presses a Cancel button, or the ESC key

The super() call sets the boolean flag closedCancel, and calls the close method. When a form is closed with closeCancel, user

 Columbus IT Partner Russia, ApS

208

Navision Axapta modifications are not saved. Closed

the form is closed

Use the flag to check whether the form has been closed.

closedCancel

set by closeCancel

This flag is set if the form was closed by a cancel action (Cancel button or ESC key). Use the flag to check whether the form was closed with Cancel.

closedOK

set by closeOK

This flag is set if an OK button closed the form. Use the flag to check whether the form was closed with OK.

closeOK

the user presses an OK button

The super() call sets the boolean flag closedOK, and calls the close method.

closeSelect

a lookup form is closed following the user's selection in the form.

closeSelect is called before close is called, and closeSelect calls closeOK.

Copy

the user performs a copy operation (CTRL+C) on the form.

If the user has selected multiple records, the super() call in copy handles this. Otherwise copy calls the corresponding method on the form control.

Cut

the user performs a cut operation on the form (CTRL+X)

cut calls the corresponding method on the form control.

doApply

the user closes a modal window

docCursor

is not called by the system. The method can be used to query the current record's data source.

docCursor was designed specifically for use by the document management system. The method returns a cursor to the current record's data source. Useful when a form has more than one data source.

Finalize

the form is closed to destruct the form object

The form destructor that releases the space allocated for the form object.

firstField

focus moves to the first field on the form

The super() call locates the first field on the form.

Init

the form is opened to create the runtime image of the form

Init is activated immediately after new. Note super() in Init must be called Before the super() call in the method, you can modify the form using the FormBuild system class. The super() call creates the form to be displayed on the screen. Also in the super() call, the data source is constructed. This is done by activating the Init method on the data source. The form data source Init creates the query to fetch data from the database and sets up links in case the form is linked to another form. In the Init method you will typically initialize variables for specific controls.

lastField

focus moves to the last field on the form

The super() call locates the last field on the form.

messageProc

Do not use. For internal use only.

new

the form is opened.

209

new is the first method called when a form instance is created. For an overview execution sequence, click .  Columbus IT Partner Russia, ApS

Navision Axapta This means that when new is executed, data source and form controls do not yet exist. When you need to add code to be executed when the form is opened, do so in the init method instead. nextField

focus moves to the next field, for example when the user presses the Tab key to advance focus

The super() call locates the next field on the form. When a form is opened, Nextfield is activated to focus on the first visible, editable field. Generally for the NextField/NextGroup and PrevField/PrevGroup operations: When a Next or Prev method is executed, the system checks the DataSource property on the control’s container to see from which table data should be displayed. The Next and Prev methods are invoked when the toolbar, the menu, or the keyboard is used.

nextGroup

focus moves to the next group of fields, for example when the user presses SHIFT+TAB key to advance focus

The super() call locates the next group on the form.

paste

the user performs a paste operation (CTRL+V) on the form.

paste calls the corresponding method on the form control.

prevField

focus moves to the previous field

The super() call locates the previous field on the form.

prevGroup

focus moves to the previous group of fields

The super() call locates the previous group on the form.

print

when the user has a form open activates the Print... command on the File menu.

A report based on the data source fields in the AutoReport field group is automatically generated. Add your own code if you want to change the layout of the standard report.

printPreview

when the user has a form open activates the Print Preview command on the File menu.

See comments to print command.

reload

Reserved for future use.

run

the form is opened, immediately after Init, to show the form

Before the super() call, you would typically do the following activate/de-activate fields etc. modify the query The super() call makes the form window appear on the screen, and performs a database search for the data to be displayed in the form. Activating the ExecuteQuery method on the form data source performs the search.

setApply

Not activated by the system.

Takes as a parameter the object, typically a form, to be activated. An apply() method must be present on the form or class and is called if a command button exists on the calling form. Tip Run the tutorial class Tutorial_Apply, and examine the code in the class and in the form of the same name.

task

the user performs some task in a form: uses the

The super() call examines the task and activates the relevant method, for example nextField if the task consists

 Columbus IT Partner Russia, ApS

210

Navision Axapta toolbar, the menu or the keyboard

in the user activating the TAB key

equal

Not activated by the system.

Used for debugging purposes. Use equal to find out whether the object given as a parameter is equal to the current object.

toString

Not activated by the system.

Used for debugging purposes. Returns the name of the form as a string.

wait

the system waits for a form to finish execution.

Methods on a form data source The table below lists the form data source methods and explains when they are executed. Method name

Is executed when...

Comments

active

the user scrolls to make a new record the current one.

The super() call makes a new record the current one.

create

the user creates a new record in the data source, for example by using the default shortcut key for insertion (CTRL+N).

The super() call creates a new record before the current one on the screen. To have the new record created after the current record, set the method’s After parameter to true.

defaultMark

the user clicks mark area (top left corner) in a grid control.

When records are loaded and presented in a grid, they are marked with a default mark value of one (1). The fact that they are marked is used for delete and for copy.

delete

the user deletes a record in the data source.

The super()activates validateDelete and (if it returns true) manages the database delete action.

deleteMarked

the user deletes (ALT+F9) one or more marked (selected) records in the data source.

If no records have been marked (selected), delete is executed.

displayOption

before a record is displayed.

displayOption is executed once for each record, before the record is displayed and after it has been loaded. The method is used to set text color and background color for individual records. Note The code lines you add to the displayOption method are not necessarily executed sequentially. Consequently you should not base you code on the first lines being executed before the last lines.

executeQuery

the form is opened for data display.

The super() call executes the query generated by the init method and displays records.

filter

the user activates the Filter command on the form shortcut menu.

Write code lines on the filter method if you want to add information to the standard filer functionality.

findRecord

(activated by findValue)

The super() call finds a specific record and makes it the current one.

findValue

the user clicks the Find Value command in the shortcut menu on a form control.

The super() call finds the specified value, and makes the record with that value the current one using findRecord.

211

 Columbus IT Partner Russia, ApS

Navision Axapta first

focus moves to the first record in the data source.

The super() call moves to the first record in the data source.

init

the form is opened.

On the basis of the properties on the data source, the super() call creates the query to load data to be displayed in the form.

initValue

a new record is created. The purpose is to fill in initial values in the record.

The super() call activates the table’s initValue method and the values initial values are filled in. In this method you would typically assign values to a new record. The system does not consider the record to be modified until the user has entered values in one or more fields.

last

focus moves to the last record in the data source.

The super() call moves to the last record in the data source.

leave

focus moves to a new record, or to a new data source.

leave is executed regardless of changes to the record. The super() call does not do anything and the method is merely used as a notification.

leaveRecord

focus moves to a new record.

Note Do not override the leaveRecord method. super() calls validateWrite and, potentially, write and should always be called.

linkActive

the user scrolls to a new record in a form with its data source linked to another data source.

The super() call activates executeQuery on the data source that the form is linked to. This method is only used when a link between two data sources has been established (by setting the LinkType property to Yes on the data source).

next

focus moves to the next record in the data source.

The super() call moves to the next record in the data source.

prev

focus moves to the previous record in the data source.

The super() call moves to the previous record in the data source.

print

the user activates the Print command in the File menu.

The super() call prints the current record using the system’s auto report facilities (the SysTableReport report, located in the Reports node).

prompt

the user activates the Filter Records command (from the Command menu or by activating the CTRL+F3).

The super() call activates the standard form used to limit the query range (the sysQueryForm form).

Refresh

The super() call updates the screen (all fields in the data source). refresh calls refreshEx. The contents of the active record are re-drawn without load from disk. You can for example use refresh if you need to update in the course of a major operation.

RefreshEx

a form is activated where records have been selected.

refreshEx is an extended version of the refresh method. It has one parameter and refreshes a single line.

RemoveFilter

the user clicks the Cancel Filter command in the shortcut menu on a form control.

The super() call resets the query, i.e. removes all modifications to the original query generated by the form data source init method.

Reread

Not activated by the system.

The super() call re-reads the current record from the database.

 Columbus IT Partner Russia, ApS

212

Navision Axapta Research

Not activated by the system.

The super() call refreshes the database search defined by the query automatically generated in the init method. Corresponds to re-activating executeQuery with the exception that research preserves the query’s filter, sorting and so on. research vs. executeQuery If you want to refresh the form with records that were inserted in a method or job that was called, then you should use research. If you want to change the query to show other records, perhaps based on a modified filter, then you should use executeQuery.

ValidateDelete

a record is to be deleted.

The super() call invokes the validateDelete method on the table. Use this method to add your own data validation checks whenever necessary.

ValidateWrite

a new or updated record is to be written.

The super() call invokes the validateWrite method on the table. Use this method to add your own data validation checks whenever necessary.

Write

the user inserts a new record or updates an existing one.

The super() activates validateWrite and (if it returns true) manages the database write action.

Methods on form controls The table below lists the form control methods and explains when they are executed. Method name

Is executed when...

Comments

activateItem

the user activates an item.

The super() call manages the activation of the item (for example a program) represented by the icon.

ListView

activeCellChanged

the user has changed cell.

Table

allItemsDeleted

the user has deleted all items in a list.

ListView

beginLabelEdit Tree

the user begins editing (re-naming) the label of a node.

You can use the return value to prevent label editing.

clicked

the user clicks a control.

Here you would place code to be activated on user-click, see the progress control example.

CheckBox CommandButton MenuItemButton Button

colLabel Table

The super() call returns the text given as column heading.

command

The super() call.

context

the user right-clicks the control.

The super() call displays the shortcut menu.

StaticText

213

 Columbus IT Partner Russia, ApS

Navision Axapta StringEdit IntEdit RealEdit DateEdit TimeEdit ComboBox CheckBox RadioButton Grid Tab Group ButtonGroup CommandButton MenuItemButton Button Window Table Tree ListView Progress Animate HTML

Data

The super() call returns the contents of a cell. Note Do not override the data method.

Table

doubleClick

the user has double-clicked an item.

ListView

editControl Table

endLabelEdit

The super() call returns the control type to be edited.

Tree

the user has ended editing (re-naming) the label of a node.

enter

the user moves focus to a control.

StringEdit

 Columbus IT Partner Russia, ApS

214

Navision Axapta IntEdit RealEdit DateEdit TimeEdit ComboBox CheckBox RadioButton Tree ListView Progress Animate HTML

expanded

the tree has been expanded.

Tree

expanding

the tree is expanding.

Tree

Filter

You can use the return value to prevent tree expansion.

the user clicks the Filter command in the shortcut menu on a form control.

StaticText StringEdit IntEdit RealEdit DateEdit TimeEdit ComboBox CheckBox RadioButton Grid Tab Group ButtonGroup CommandButton MenuItemButton

215

 Columbus IT Partner Russia, ApS

Navision Axapta Button Window Table Tree ListView Progress Animate HTML

gotFocus

the user brings the control into focus.

StaticText StringEdit IntEdit RealEdit DateEdit TimeEdit ComboBox CheckBox RadioButton Grid Tab Group ButtonGroup CommandButton MenuItemButton Button Window Table Tree ListView Progress

 Columbus IT Partner Russia, ApS

216

Navision Axapta Animate HTML

HDC

Not activated by the system.

Handle to Device Context.

the user clicks the control.

The super() call displays the text in the HelpText property on the control, on the table or on the extended data type. The precedence is in the order indicated: control, table, and data type. Display another help text by overriding the method.

the user enters input in a bound control.

If you override the method, return false to suppress search for input, and use the field as a normal input field or perform a custom search. The super() call in InputSearch calls Filter(Value) on the control which in turn calls Filter on the data source

Image

helpField StaticText StringEdit IntEdit RealEdit DateEdit TimeEdit ComboBox CheckBox RadioButton Grid Tab Group ButtonGroup CommandButton MenuItemButton Button Window Table Tree ListView Progress Animate HTML

inputSearch All controls

217

 Columbus IT Partner Russia, ApS

Navision Axapta field. Any search results are appended to the existing query. To search in the entire data set, clear the filter before searching. itemDeleted

the user has deleted an item in the tree or list.

Tree ListView

itemInserted ListView

jumpRef StaticText StringEdit

the user has inserted an item in the tree or list. the user activates the shortcut keys (default CTRL+ALT+F4) or clicks the Go to main table command in the shortcut menu to jump to the field’s main table.

The super() call changes data source, shows the table.

IntEdit RealEdit DateEdit TimeEdit ComboBox CheckBox RadioButton Grid Tab Group ButtonGroup CommandButton MenuItemButton Button Window Table Tree ListView Progress Animate

 Columbus IT Partner Russia, ApS

218

Navision Axapta HTML

Leave

the user moves focus out of a control.

StringEdit IntEdit RealEdit DateEdit TimeEdit ComboBox CheckBox RadioButton Tree ListView Progress Animate HTML

lockDC

Not activated by the system.

Lock Device Context.

Image

Lookup StringEdit

the user uses the lookup facility. For more information about relations and lookup, click .

IntEdit RealEdit DateEdit

lostFocus

the user brings the control out of focus.

StaticText StringEdit IntEdit RealEdit DateEdit TimeEdit ComboBox CheckBox

219

 Columbus IT Partner Russia, ApS

Navision Axapta RadioButton Grid Tab Group ButtonGroup CommandButton MenuItemButton Button Window Table Tree ListView Progress Animate HTML

Modified StringEdit IntEdit

an edit field (StringEdit, IntEdit, RealEdit, DateEdit, TimeEdit) is exited after editing a value in a CheckBox, a RadioButton, a ComboBox, or a ListBox has been changed.

The super() call manages the table update (by a sequence of calls to Validate on the data source, ValidateField on the table, and Modified on the data source).

RealEdit DateEdit TimeEdit ComboBox CheckBox RadioButton Tree ListView Progress Animate HTML

mouseDown

the user releases the mouse button.

 Columbus IT Partner Russia, ApS

220

Navision Axapta

StaticText StringEdit IntEdit RealEdit DateEdit TimeEdit ComboBox CheckBox RadioButton Grid Tab Group ButtonGroup CommandButton MenuItemButton Button Window Table Tree ListView Progress Animate HTML

mouseMove

the user moves the mouse pointer.

StaticText StringEdit IntEdit RealEdit DateEdit TimeEdit

221

 Columbus IT Partner Russia, ApS

Navision Axapta ComboBox CheckBox RadioButton Grid Tab Group ButtonGroup CommandButton MenuItemButton Button Window Table Tree ListView Progress Animate HTML

mouseUp

the user presses the mouse button.

StaticText StringEdit IntEdit RealEdit DateEdit TimeEdit ComboBox CheckBox RadioButton Grid Tab Group

 Columbus IT Partner Russia, ApS

222

Navision Axapta ButtonGroup CommandButton MenuItemButton Button Window Table Tree ListView Progress Animate HTML

Paint Window

The super() call draws the background and displays the .bmp file. Do not use.

processBase HTML

Do not use.

processForm HTML

Do not use.

processLink HTML

Do not use.

processPicture HTML

Do not use.

processTitle HTML

rowLabel Table

selectionChanged

The super() call returns the text given as row heading. the user has moved the selection to another item.

Tree ListView

selectionChange

the user alters his selection.

ComboBox RadioButton

selectionChanging

the user is moving the selection to another item.

You can use the return value to prevent selection change.

Tree ListView

tabChanged

a change of tab pages has taken place.

Tab

tabChange 223

immediately before change of tab page.  Columbus IT Partner Russia, ApS

Navision Axapta Tab

If the method returns false, the system does not change tab page.

textChange

the user enters characters in a field.

StringEdit IntEdit RealEdit DateEdit TimeEdit

toolTip

the user moves the mouse pointer over a control.

StaticText StringEdit IntEdit RealEdit DateEdit TimeEdit ComboBox CheckBox RadioButton Grid Tab Group ButtonGroup CommandButton MenuItemButton Button Window Table Tree ListView Progress Animate

 Columbus IT Partner Russia, ApS

224

Navision Axapta HTML

unlockDC

Not activated by the system.

Unlock Device Context.

exits a control after entering values.

Here you can use a member function to get the value. For example this.text(); if the control is a StringEdit and this.selection(); if the control is a ComboBox. The super() call activates validateField on the database table.

Image

Validate StringEdit IntEdit RealEdit DateEdit TimeEdit ComboBox CheckBox RadioButton Tree ListView Progress Animate

HTML

6.7. Forms: Examples An example: a typical form from the standard application

Pic. 6-29 CustTable is one of the central forms used to create and maintain customer information in the standard application. Also, CustTable is an excellent example of how forms are generally created in the application: 225

 Columbus IT Partner Russia, ApS

Navision Axapta • Based on one table only • Auto-generated layout • Designed with tab pages to display and enter information in the central table, and buttons to open forms with information from other tables • Practically no code written on the form itself but on the underlying table The following section reviews central issues and concerns when creating a form like CustTable, particularly which properties to set and where to add X++ code.

Selecting a data source Once you create the form by clicking New in the Forms node's shortcut menu, the next step is to select a data source using a drag-and-drop operation to move one or more tables from the Tables node. CustTable is typical of the large majority of forms in the standard application in that it uses one table only as its underlying data source: CustTable. When CustTable has been moved to the Data Sources node, you can view the table's properties.

Pic. 6-30 To manipulate the underlying data from the form (as opposed to merely viewing data), the AllowEdit, AllowCreate and AllowDelete properties must be set to Yes. In order to make use of the system's capability to create queries on the basis of the relations set up in the database, set the property AutoQuery to Yes. To make the system automatically scroll in a child form when the user scrolls in the parent form, set the LinkType property as well. This concludes the work to be done in the Data Sources node. The next topic is the Designs node.

Designing the layout At first glance the CustTable form may look quite complex with eight tab pages and the row of buttons. However, there are actually only few, central tasks involved which are repeated several times.

The tab with tab pages To create a tab with pages, first create the container tab by clicking New Tab, and the individual tab pages by clicking New TabPage on the container.  Columbus IT Partner Russia, ApS

226

Navision Axapta If you have more than one data source, set the DataSource property on the individual pages. On the individual pages, Caption should be set. To ease later modifications the caption should not just be a text but rather a label. When the page displays a large number of fields, like for example the General tab page, the information may be displayed in several columns by setting the Columns property.

Groups and headings Generally each tab page holds a number of groups with the groups of fields from the CustTable table; the General tab page, for example, consists of four groups of fields: General, Exchange, Credit, and Administration. Simply moving them from the corresponding ones in the Data Sources node to the tab pages in the Designs node created the latter three groups. Having moved a group, only two properties should be set: Name and Caption. Again, any text that you enter should be a label. The General group is an example of a group where the groups from the database table have not been moved directly. General consists of three fields from three different groups; each of these fields has been moved individually. The DataSource and DataField properties should be set for all fields; this is automatically done by the system. The DataGroup property should also be set. You can modify the auto-selected frame by setting the FrameType and FramePosition properties.

Re-arranging the sequence of fields within a group Within the individual group on the form, controls for fields are added in the sequence the fields occur in the table. To re-arrange the fields do one of the following: • • •

Click the Edit command in the shortcut menu to see the finished form in design mode. Here you can move controls within the group. Re-arrange the fields in the Design node. Re-arrange the fields in the group in the table.

Alignment To align the controls, use the properties AlignChildren and AlignChild. Setting AlignChildren to Yes means, “yes, I will align my child controls”. Setting AlignChild to Yes means, “yes, I accept to be part of my parent control’s alignment scheme”

Lookup and data validation On practically all of the tab pages in the CustTable form, you see the small lookup icon . The icon indicates that by clicking it you get a list of the possible field values. This serves the dual purposes of helping the user, and ensuring that an invalid value is not accidentally entered. As you have seen if you have made your own copy of the CustTable form, the lookup icons were added automatically when the fields were dragged to the Designs node; there was no extra work involved. This is because the necessary relations were defined in the underlying database. 227

 Columbus IT Partner Russia, ApS

Navision Axapta In the CustTable form there are examples of the two basic types of relations • •

Single field relations and Multiple field relations

The lookup on Country is an example of a single field relation.

Pic. 6-31 Single field relations are defined on the extended data type. The field Country in the CustTable table is based on the extended data type CountryId.

As shown above, the extended data type CountryId has a relation to the field CountryId in the table Country. This means that when the user clicks the control labeled Country in the “Address” tab page, the system looks up information in the Country table's CountryId field. However, as you can see from the illustration above, there is also a column called Description giving the full-length text. This is additional information added automatically when the TitleField2 property has been set on the Country table.

 Columbus IT Partner Russia, ApS

228

Navision Axapta

Pic. 6-32 The lookup on State is an example of a multi-field relation.

Pic. 6-33 Multi field relations are created on tables. A relation is created on the CustTable table that stipulates that • •

229

The Country field has a relation to CountryId in the State table and The State field has a relation to StatId in the State table

 Columbus IT Partner Russia, ApS

Navision Axapta

When the user clicks the control labeled State in the Address tab page, the system looks up information in the Country table's CountryId, and StatId fields. As in the single fields relation described above, the additional information in the Description column is added automatically when the TitleField2 property has been set on the Country table. Whether a lookup button is actually displayed is defined by the LookupButton property on the individual control; the property is automatically set to Auto. When the relations have been defined, the lookup functionality is there - whether the button is actually displayed or not.

6.8. An additional benefit of creating relations... Having created a relation, whether it is a single or a multiple field relation, gives the end user an additional benefit using the form in the application. When he right-clicks, for example, the State field, a shortcut menu with the Go to main table command is opened.

Pic. 6-34 Go to main table means: open the form displaying data from the table in which the information was originally stored. In the Customer example this means that when the user clicks Go to main table on the State field, the State form is opened displaying information from the State table.

Creating a relationship There are two relationships in MorphX: • •

Single field Multiple field

You can add conditions to both types at runtime based on user input. Relationships are defined at different places in MorphX.

 Columbus IT Partner Russia, ApS

230

Navision Axapta

You can define a relationship on...

This allows you to create

an Extended Data Type

Single field relationships Conditions on a relationship

a table

Single field relationships Multiple field relationships Conditions on a relationship

Multi line fields One of the controls you see on the Address tab page is the control for address information labeled Address. The address field is based on the Addressing extended data type that is a String field that has its StringSize property set to Auto. The only modification necessary following the system's auto-generation of the StringEdit control is to set the control's MultiLine property to Yes.

The ButtonGroup The group of buttons to the right in the CustTable form consists of a MenuItemButton and five MenuButtons with additional MenuItemButtons. The buttons are all used to activate other forms in the application. To have a button control open another form you merely set the Module, Group and Function properties on the control.

Caption on child form When you open another form, for example CustTrans, you will notice that in addition to the form's own caption some information has been added in parenthesis: account number and company name. This information comes from the properties TitleField1 and TitleField2 on the CustTable table.

Automatic scrolling in child form (synchronizing) You will notice when you open another form, again for example CustTrans, and scroll in the parent form is that the information in the child form scrolls as well. In other words, the information in the forms is automatically synchronized. This was set up when you set the LinkType property on the data source to Yes.

An example of a Progress control This example illustrates the programming of a Progress control.

Pic. 6-35 The form has a progress bar, and integer field to show the current integer value illustrated by the bar and a button to start the progression. All controls are unbound. In the Application Object Tree, the form looks like this: 231

 Columbus IT Partner Russia, ApS

Navision Axapta

Pic. 6-36 Code is written on one method only, the method that is activated when the user presses the button labeled “Start”. Line void Clicked() { 1

FormProgressControl p;

2

FormIntControl i;

3

int j;

4

i = element.design().control(control::intEdit);

5

p = element.design().control(control::progress);

6

for (j=0; j