DG DAW 2010-01-20.framework Development Guide.v2.0.0.0
DG DAW 2010-01-20.framework Development Guide.v2.0.0.0
Developer's Guide
Version
2.0.0.0
Document title: Document type: Author Publish date File name Version
: : : : : :
Dynamics Anywhere Nieuwe Bosweg 10 3341 LH Hendrik-Ido-Ambacht The Netherlands Telephone: +31 78 68 11 234 Mail address: [email protected] Internet: www.dynamicsanywhere.com
2010 Dynamics Anywhere. All rights reserved. The information in this document is confidential, constitutes the intellectual and proprietary property of Dynamics Anywhere, and is protected by intellectual property laws and international intellectual property treaties. The names of actual companies and products mentioned herein may be the trademarks of their respective owners. No part of this document may be reproduced or transmitted in any form or by any means, electronic or mechanical, for any purpose, without the express written permission of Dynamics Anywhere. The information contained in this document is subject to change without notice. Dynamics Anywhere does not warrant that the information contained in this document is error free.
Table of contents
1. INTRODUCTION ........................................................................................................................................................ 1
WHO SHOULD READ THIS GUIDE? .................................................................................................. 1 WHAT IS DISCUSSED IN THIS GUIDE? ............................................................................................... 1 NEW IN THIS VERSION ................................................................................................................... 1 INTRODUCTION ............................................................................................................................ 2 THE FRAMEWORK WITHIN AX ........................................................................................................ 3 ON SESSIONS ............................................................................................................................... 4
3.1 THE APPLICATION CONFIGURATION TAB .......................................................................................... 5 3.1.1 Application object layer within framework data ............................................................. 6 3.1.2 Application properties ..................................................................................................... 6 3.1.3 Menu properties .............................................................................................................. 6 3.1.4 Label properties ............................................................................................................... 6 3.2 THE FORM CONFIGURATION TAB .................................................................................................... 7 3.2.1 Form properties ............................................................................................................... 8 3.2.2 User controls .................................................................................................................... 8 3.2.3 Properties overview ......................................................................................................... 8 3.2.4 Data grid column configuration..................................................................................... 10 3.2.5 Button actions................................................................................................................ 11 3.2.6 Variables ........................................................................................................................ 12 3.3 GENERAL TAB ............................................................................................................................ 13
4. A CASE: HELLO WORLD PART 1 ............................................................................................................................... 14
4.1 CREATING A NEW APPLICATION..................................................................................................... 14 4.2 ADDING FORMS TO YOUR APPLICATION .......................................................................................... 15 4.2.1 Configuring the hello world form................................................................................... 15 4.2.2 Configuring the logout form .......................................................................................... 17 4.3 TESTING THE APPLICATION ........................................................................................................... 19
5. CUSTOMIZING THE GENERATED APPLICATION AND FORM CLASSES ....................................................................... 22
5.1 INTRODUCTION .......................................................................................................................... 22 5.2 RESPONDING TO USER SUBMITS (BUTTON AND KEY PRESSES) ............................................................. 23 5.3 INITIALIZING OBJECTS WHEN THE FORM LOADS ................................................................................ 24 5.4 RESPONDING TO USER INPUT FROM A PREVIOUS FORM ..................................................................... 24 5.5 AN OVERVIEW OF OTHER FORM EVENT METHODS ............................................................................ 25 5.5.1 OnControlCheckedChanged ........................................................................................... 25 5.5.2 OnControlSelectedIndexChanged .................................................................................. 25 5.5.3 OnControlTextChanged ................................................................................................. 25 5.5.4 OnDeactivate ................................................................................................................. 25 5.5.5 OnInit ............................................................................................................................. 25 5.6 AN OVERVIEW OF APPLICATION EVENT METHODS............................................................................. 25 5.6.1 Onload ........................................................................................................................... 25 5.6.2 OnLogoff ........................................................................................................................ 25 5.6.3 OnMenuSelect................................................................................................................ 26 5.7 RESPONDING TO EVENTS IN GENERAL, CALLING EVENT METHODS EXPLICITLY FROM CODE ....................... 26
6. A CASE: GETTING SOME ITEM INFORMATION ......................................................................................................... 27
6.1
CREATE A FORM THAT DISPLAYS THE RESULT ................................................................................... 29 ADDING SOME CUSTOM CODE TO YOUR APPLICATION ....................................................................... 31 TESTING YOUR MODIFICATIONS .................................................................................................... 32
7.1 INTRODUCTION .......................................................................................................................... 33 7.2 CLEANING UP THE TRANSACTION LOG ............................................................................................ 33 7.3 DEBUGGING THE APPLICATION...................................................................................................... 34 7.3.1 Notes on application state ............................................................................................. 34 7.3.2 Breaking your code with a throw so you can debug...................................................... 34 7.3.3 Debugging your code ..................................................................................................... 36
8. A CASE: SHOWING INFORMATION IN A DATA GRID ................................................................................................ 38
ADDING A NEW FORM TO THE DESIGNER ........................................................................................ 38 ADDING CODE TO LOOK UP THE ITEM ............................................................................................. 40 SETTING UP THE DATA GRID ......................................................................................................... 41 NAVIGATE TO THE NEW FORM ...................................................................................................... 42 TEST THE MODIFICATION ............................................................................................................. 43
9.1 METHODS OF THE APPLICATION CLASS ........................................................................................... 44 9.1.1 About the application class............................................................................................ 44 9.1.2 Getters for form classes ................................................................................................. 44 9.1.3 Getters/setters for variables .......................................................................................... 44 9.1.4 FindLabel ........................................................................................................................ 44 9.1.5 GetDeviceTypeId ............................................................................................................ 44 9.1.6 GetHostname and GetUserId ......................................................................................... 44 9.1.7 GetLanguageId .............................................................................................................. 44 9.1.8 Get/SetMainParam and Get/SetMainParamContainer ................................................ 44 9.1.9 Logoff ............................................................................................................................. 44 9.1.10 ReturnFromForm ........................................................................................................... 45 9.1.11 ShowFormByInstanceId and ShowFormByConfigId ....................................................... 45 9.1.12 ShowMainMenu............................................................................................................. 45 9.2 METHODS OF THE FORM CLASS ..................................................................................................... 45 9.2.1 About the form class ...................................................................................................... 45 9.2.2 Getters for user control classes ..................................................................................... 45 9.2.3 Getters/setters for variables .......................................................................................... 45 9.2.4 Get/SetFormParam and Get/SetFormParamContainer................................................. 45 9.2.5 GetHostname and GetUserId ......................................................................................... 45 9.2.6 Get/SetMainParam and Get/SetMainParamContainer ................................................ 46 9.2.7 IsReturnedFromForm ..................................................................................................... 46 9.2.8 PerformButtonNavigation ............................................................................................. 46 9.2.9 ReturnFromForm ........................................................................................................... 46 9.2.10 ShowForm ...................................................................................................................... 46 9.3 METHODS OF USER CONTROL CLASSES ........................................................................................... 46 9.3.1 About the user control classes ....................................................................................... 46 9.3.2 BoundDataCount (data grids only) ................................................................................ 46 9.3.3 BoundDataContainsField (data grids only) .................................................................... 47 9.3.4 Checked (checkbox only) ................................................................................................ 47 9.3.5 ClearBoundData (data grids only) ................................................................................. 47 9.3.6 FillFromList (data grids only) ......................................................................................... 47 9.3.7 FillFromQuery (deprecated) ........................................................................................... 47 9.3.8 GetBoundData, GetBoundDataStruct (data grids only) ................................................ 47
HasFocus and SetFocus .................................................................................................. 47 IsSubmitTarget (buttons only) ....................................................................................... 47 ListFields (data grids only) ............................................................................................. 47 SelectedIndex (data grids only)...................................................................................... 47 Text ................................................................................................................................ 47
10.1 10.2
11.
AUTOMATICALLY CONTINUE AFTER SELECTING AN ITEM FROM THE LIST................................................ 48 ADDING CODE TO THE ONREACTIVATE METHOD .............................................................................. 48
SESSIONS AND SETUP......................................................................................................................................... 50
ACTIVE SESSIONS FORM .............................................................................................................. 50 TRANSFERRING SESSIONS TO ANOTHER DEVICE ............................................................................... 50 FRAMEWORK PARAMETERS ......................................................................................................... 51
NOTES ................................................................................................................................................................ 52
1. Introduction
This guide explains how the Dynamics Anywhere Framework for Dynamics AX works, and how a developer can use it to create or modify a mobile application for the framework.
2. Framework overview
2.1 Introduction
Central to the Dynamics Anywhere Framework is the Dynamics Anywhere Portal. Utilizing Dynamics AX Business Connector technology to connect to Dynamics AX, the Dynamics Anywhere Portal carries Dynamics AX into the mobile world. Designed specifically to work flawless with any mobile device, the Dynamics Anywhere Portal presents the user with an attractive, fast and reliable user interface. In addition, the user interface is designed to make the most of the mobile device, providing a clutter free view of the application and making full use of additional resources like barcode scanners and RF tag readers to improve user productivity. The following figure shows the overall architecture and the components that constitute the Dynamics Anywhere Mobile Business Solution:
AOS
HTML
XML
DAWFW Webservice
DAW FrameWork
PDA
Many mobile devices have a limited implementation of their web browser due to their design and configuration, making ordinary HTML based solutions unsuitable for use on a mobile device. The Dynamics Anywhere Framework will run on any device with a browser, and fully supports using multiple device types and form factors simultaneously. The system and hardware requirements for each component must be met before installing. When you have determined that your host environment meets the requirements that are provided in the following topics, proceed to the appropriate installation section. This guide deals mostly with configuring and modifying applications built within the Dynamics Anywhere Framework. For details on installation and configuration of the Portal, Web service and Framework in AX, please refer to the Installation Guide.
Business Logic (X++) AX business logic AX business logic Custom extension Application Application to Extended Extended application Custom Form extension Form Extended to form Extended
AX Database
Dynamics Anywhere FW
UI Config and default properties Application Application Application Form Form Form UI UI UI Element Element Element
Shown above is a diagram showing how the different parts work together, and how the framework interacts with the rest of AX. User actions are received from the Portal (using the Dynamics AX Business Connector). The event handler looks up the session that goes with the user/device (or instantiates a new one if the user is logging in), and passes the event on to the Application or Form objects (for instance, a user scanning a barcode in a textbox would result in a submit event being called on the form class object). Classes are generated automatically for forms and application by the framework whenever an application or form is added to the framework using the user interface designer, and are specific for that application or form. As these classes exist in the AOT of AX, custom extensions of those classes allow the developer to validate user input, register data, or call other AX business logic. Furthermore, since most user interface objects created when designing the user interface of the application will have a generated representation in the AOT, it is impossible to accidently reference an object that does not exist, and developer tools like code completion help to quickly add and customize the mobile application.
2.3 On sessions
Whenever a user logs on to the framework, a session is created for this user/device. The framework creates this session using the configured application. The session represents the running instance of the application blueprint. The data stored in the user controls and associated variables are specific to this session, and separated from other sessions of other users that may be running simultaneously. Storing this data in tables in AX instead of as part of the web session makes sessions state persistent. If a device resets, or the web session is lost, or even the business connector session, the application state will be preserved, and upon logging in, the application will continue where it left off.
3. The designer
Developers can use the designer to create or modify the user interface of a mobile application for the Dynamics Anywhere Framework, and to design some behavior and navigation for the application. You can find the designer by selecting DAW Framework from the main menu of Dynamics AX, and then selecting Application Configuration. Most tables shown in the designer display a column called Application Object Layer. Records are stored with this column set to the current AOL, and you can only modify records that are set to the current AOL. If the record is set in a different AOL, editing the record will create a copy of the record with the AOL set to the current layer. When rendering the user interface, the framework will use the topmost AOL version of the record, so multiple parties can work on the user interface in the same way they would on application objects in AX. The designer window has three tabs, called Application Configuration, Form Configuration and General.
This tab contains a list of the applications configured in the framework, and below that the menu configured for the selected application and the labels created. Labels can be used on many objects in the framework, and allow the developer to create a single reference to text that can be in several languages, and may be formatted for several
devices (with abbreviations for devices with small screens, and verbose texts for devices with large screens). Whenever an application is created in the designer by adding a record to the Application Configuration grid, a project called D2MFW_<project name> is automatically created in the AOT, together with a class named <project name>Main. As forms are added to the mobile application, automatically generated classes for these forms are also added to this project.
Note:
Note:
Each label should at least have an entry for en-us, as this is the language the framework uses when a label in the language of the user cannot be found. If the enus label is missing in this case, the framework could behave erratically or crash. A dropdown allows you to select an AX sys label for the Text property. If you use AX sys labels you only have to provide an entry for en-us, it will be translated to the user language automatically.
This tab contains the forms in the selected application, as well as the global variables that are available throughout the application and local variables that are linked to a specific form. Whenever a form is created, a class named <application name><form name> will be created in the application project in the AOT. Forms contain user interface elements (user controls), as well as local variables that are available through the form class.
User control properties for the selected user control are displayed below the control configuration grid, and can be modified. Only the properties appropriate for the control type are displayed.
Clear on reactivate Label, Textbox, Grid, Checkbox Clears the control value upon reactivating the form (see 5.4) Data grid select Button When a grid is present on the form, this causes the data of the selected row on the grid to be copied to any variables linked to the columns Get caption from EDT Label, Textbox Gets and displays a caption for the label or textbox from the extended data type of the linked variable Hotkey Button Hotkey (function key) linked to control Include hotkey in caption Button Show hotkey in caption (e.g. F1: Back) Label id Label, Textbox, Button, Checkbox Reference to the label show as text with the control Linked variable Label, Textbox, Button, Grid, Checkbox Name of the variable linked to the value of the control Linked variable form id Label, Textbox, Button, Grid, Checkbox Either empty (for a global type variable), or the id of the current form (for a local type variable) Read-only Label, Textbox, Button, Grid, Checkbox Read-only controls show up greyed out Required Textbox When a button with the validate textbox property set is pressed, all textboxes with the required property set must have data, otherwise an error is displayed. Selected index Grid Selected index
Property: Applies to: Description: Property: Applies to: Description: Property: Applies to: Description: Property: Applies to: Description: Property: Applies to: Description:
Property: Applies to: Description: Property: Applies to: Description: Property: Applies to: Description:
Text Label, Textbox, Button, Literal HTML, Checkbox Literal text to use instead of a label (you can use AX sys labels here) Validate textbox Button See Required Visible Label, Textbox, Button, Grid, Checkbox Visible property (invisible controls are not show)
Property: Description:
Grid column Order of the column within the grid. Make sure the numbers are consecutive (no numbers are skipped). Label id Reference to label shown in header of the column. Column width Width in pixels of the column. Use a width of 0 to hide the column. Query result list If a result list is used to populate the grid, this references the struct field used for this column. Linked variable Name of the variable linked to the value of this column. Linked variable form id Either empty for a global type variable, or the id of this form for a local type variable.
Creating a column definition for a data grid is not required. If the developer doesnt provide one, all of the columns in the data linked to the data grid are displayed.
Dynamics Anywhere Framework Developer's Guide
10
Button actions are performed by the framework when calling the onSubmit method of the form class. If you want to prevent the execution of the button action in certain cases (for instance if a validation fails), override the "onSubmit method of the form, and prevent the call to the super method (by either returning before it is called, or throwing an error). None/Custom This button action is used when some custom action is performed (for instance calling some AX business logic) without the need to navigate to another form. Main menu This button action causes the application to return to the main menu, regardless of whether there are other forms on the form stack or not. Logout This button action causes the application to return to the main menu, regardless of whether there are other forms on the form stack or not. Show form (create always) This causes the current form to be placed on the form stack, and a new form (specified in the button action form id) to be designated as the new current form. If no instance exists of the form, it is created. A single instance of a form can be added to the form stack multiple times, so take care when using this button action Show form (create or return) This button action does almost the same as Showform (create always), with one exception; if the new form (specified in the button action form id) is already available in the form stack, all forms above it on the stack are removed, and the new form is designated as the new current form. This is especially useful when the application has to loop a sequence of forms many times (for instance, when performing an item pick).
Dynamics Anywhere Framework Developer's Guide
11
Return from form This button action, which exists in several variants (OK, Cancel, Yes, No, etc.), pops the top most form from the form stack and makes it the new current form, in effect exiting the current form and returning to the previous one. When the previous form is reactivated in this way, the onReactivate method on the form class is called. The value shown in parenthesis corresponds to a parameter passed to this method, allowing the developer to evaluate it and take some appropriate action. Use this button action to create pop-up style forms, for instance when you need a pop-up where the operator answers yes or no in response to some situation. See 5.4 for an example.
3.2.6 Variables
Variables are used to store data in your session. Each session has its own personal set of variables, which other sessions have no access to.
Default value.
Variables can be either global or local. Global variables are available through the generated class for the application (named <application name>Main), and local variables are available through the generated class for the form (named <application name><form name>). User controls may be linked to variables (either of the global or local variety, with the restriction that they are on the same form for the latter). Variable linked to control
When displayed, the data of the variable is automatically used as the value for the user control. When the value of the user control is modified by the user, the modified value is automatically stored in the variable. The base type of the variable should be appropriate for the user control it is linked to (for instance, a date type variable may be linked to a textbox, but not to a checkbox.
12
Allowed Base Type Enum (of type NoYesId) Interger, Int64 Date, Guid, Integer, Int64, Real, String, Time, Enum Type should be compatible with the data displayed
Variables may also be linked to grid columns. When the user presses a button that has the data grid select property set, the data in the column of the selected row of the data grid is copied to the linked variable.
On this tab, device types can be defined, as well as the fonts used in the mobile application. These settings are for all applications, not just the selected one. Whenever anything is configured for several device types, (such as labels, or the fonts configured for controls, or the number of lines for a data grid) the framework will consider the screen resolution of the used mobile device, and choose the setting for the device type that matches that of the used device, or is the next smallest, or failing that, the next largest. This ensures that the best possible configuration is selected for the used device.
13
Please note, we are using AX syslabels in this example out of convenience, were not indicating that as a rule, you should too, as arguments can be made for and against using the syslabels provided by AX.
Try to create the labels for all languages you wish to support from the start. However, always create at least an entry for en-us for each label you create.
Dynamics Anywhere Framework Developer's Guide
14
You can use this number to sort your forms in this grid.
Next, select the first form, and add a new user control called LblHelloWorld. Set the properties as in the example below.
15
Add a user control of type Literal HTML, called LitHorizontalLine. Set control type to Literal HTML and save (^S) to update the shown properties. Then, set the properties as in the sample below2. Please note, once you save a record you cant change name or type anymore. Dont forget to select the control type.
Literal HTML tags need to be XHTML (conform to XML). Finally, add a user control of the type button named BtnOk (dont forget to set the control type before saving), and set the properties as in the sample below. Use tab order to set the order in which controls show up in your form.
Causes the form to exit when pressed. We now have a form that displays a single fixed line of text, and has a button that exits the form.
Only properties appropriate to the control are show. If you dont see the properties change, save your record, reselect the record or refresh the screen.
Dynamics Anywhere Framework Developer's Guide
16
Then, select the form LogOut, and add a label control named AreYouSure to it, set the properties as shown below.
Add a literal HTML control named LitHorizontalLine, and set the properties like this.
17
Logs the user out when pressed. Now, well change the default button for the logoff form to BtnYes. Youll notice you get an error stating the values displayed in the form are not current. This is because the framework sets the default button value to the first button you add to the form in the background. Press F5 to refresh the screen, and then change the default button value for the logoff form to BtnYes.
18
Finally, we need to set up the main menu to open the forms we just added. Go back to the tab Application Configuration, go to the main menu, and select the forms added in the form config id property of the menu items.
If youre creating a new user, dont forget to go to the Employee/Roles form and select a role for the user, and save the record, or the user may not be able to use the application correctly.
19
Now, start the browser (use the PDA option on the desktop of the training VPC) and log in using the user name and password configured in the user form.
You can do this by printing the operator badge and scanning it into the login field (from the DAW Users form, select one or more users, and then select print operator badge).
As you probably dont have a barcode scanner available, you can also manually enter the user name, followed by the / character, and finally the password (for user 1000 in our example, use 1000/123). If you find you have trouble logging in, check if youre using the correct user name and password. Also, when using VPC with a non US keyboard, some characters show up under different keys so make sure youre not accidently entering a character other than the / character as the separator character (open up notepad to test this if you are not sure).
20
You now see the main menu (it may look slightly different depending on the type of browser youre using).
Select OK to go back to the main menu, and from there select the menu option Log off.
21
Looking at the sample shown above, you can see that for each form in the application, a getter function (get<form name>) is added to the application class, and for each global type variable, a getter/setter (var<variable name>) is added. On the form classes, each user control gets a getter function (get<user control name>), and any local type variable also gets a getter/setter (var<variable name>). Finally, each form also gets a getMain function, which returns the application class for that form.
22
This example has a couple of interesting things to point out. First of all, the custom code is only executed when the OK button was submitted. This is very important, if you do not check the submit target the custom code will be executed on each submit, even simple screen refreshes. You can check if a submit event is caused by a certain user control (nearly always a button) by feeding the _submitTargetId parameter to the isSubmitTarget method of the control. Another interesting point to make is the use of throw error. The text provided with this throw will be shown to the user. In addition, the throw prevents the call to the super method, which might have caused the application to navigate to another form. Finally, the throw rolls back any updates in the current transaction, which means that when the user sees the form with the error message, the application session is in the same state is was in before the user submitted the faulty data. If you want to prevent the button press to navigate to another window, but you dont want to roll back the current transaction, you could also return the value D2MFWEventHandleResult::OK, without calling super(), so any navigating configured as a button action is bypassed.
23
Make sure you perform the call to super() after you have finished processing the user submit, if you call it earlier it may navigate to another screen, and variables may have been set or cleared, and business logic may have been called, during navigation.
Handle the call to super first, as this will clear all controls that have the clear on load property set.
24
In this example, code is added for when the form is reactivated after a form called AreYouSure exits (presumably, this form navigated to the AreYouSure form). You can see how to respond differently depending on the result the AreYouSure form exited with. You can find an example of this in chapter 10. Handle the call to super first, as this will clear all controls that have the clear on reactivate property set.
5.5.1 OnControlCheckedChanged
This method is called when a control on the form has its checked property changed by the operator. Please note, this event will execute after the user submitted the changes by pressing a button or function key, so this is not real-time!
5.5.2 OnControlSelectedIndexChanged
This method is called when a control on the form has its selected index property changed by the operator. Please note, this event will execute after the user submitted the changes by pressing a button or function key, so this is not real-time!
5.5.3 OnControlTextChanged
This method is called when a control on the form has its text property changed by the operator. Please note, this event will execute after the user submitted the changes by pressing a button or function key, so this is not real-time!
5.5.4 OnDeactivate
This method is called when a form navigates away to another form by a showform button action or by calling <formClass>.ShowForm.
5.5.5 OnInit
This method is called when a form is instantiated, and is usually only called once during the lifetime of an application session.
5.6.1 Onload
This method is called when the application is loaded. It is not called when the user logs in again on an already instantiated application.
5.6.2 OnLogoff
This method is called when the user logs off from the application. It is not called if the web session expires, only when the framework performs a log off.
25
5.6.3 OnMenuSelect
This method is called when a menu option is selected. When overriding this method, pass over the call to super if you dont want to perform the action associated with the menu item (opening a form, submenu or other application).
5.7 Responding to events in general, calling event methods explicitly from code
When responding to events in general, make sure you return a D2MFWEventHandleResult value if required (some event methods are void methods and dont require the return of a result value). Use either the return value of super, or return D2MFWEventHandleResult::OK if you didnt call super. This is important because the framework will take a cue from the returned value for further navigation, and returning a value other than D2MFWEventHandleResult::OK may result in unexpected behavior. You can also explicitly call an event method when reacting to another event method. In the example below, we have a form where the user inputs an item id. Upon returning from a list form where the user selected an item from a list, we accept this item and call the onSubmit method to simulate the user pressing the OK button.
public D2MFWEventHandleResult onReactivate( D2MFWFormInstanceID _returnedFromFormID, D2MFWFormResult _formResult) { D2MFWEventHandleResult rv = super(_returnedFromFormID, _formResult); if((_formResult == D2MFWFormResult::OK) && (this.getMain().getListItems().isReturnedFromForm(_returnedFromFormId))) { // set ItemId in textbox and simulate press OK this.getTxtScannedData().text(this.getMain().varItemId()); return this.onFormSubmit(this.getBtnOk().getControlInstanceID()); } return rv; }
Please note that the return value from onSubmit is returned instead of the return value from the call to super. This is especially important when explicitly calling onFormSubmit, failing to do so for this method may result in buttons with the main menu or logout button action not working anymore.
26
Next well add two forms called ScanItemId and ShowItemName (dont forget to set the Title label id), and two global type variables called ItemId and ItemName (with matching extended data type, although it is not a requirement that they have the same name).
Select the form ScanItemId, add a user control called TxtItemId. Set up a linked variable to this control here.
27
28
Finally, refresh the screen by pressing F5, and set the default button property of the form ScanItemId to BtnOk.
29
And finally, add a button called BtnOk. Using show form (create or return) instead of return from form, so the load of ScanItemId is triggered, and the textbox is cleared.
Finally, go back to the Application Configuration tab, and add a main menu line for the new form.
30
Select the class HelloWorldScanItemId, right click and select Override method, and then select OnFormSubmit. Add the following code in the overridden method.
public D2MFWEventHandleResult onFormSubmit(D2MFWControlInstanceID _submitTargetID) { D2MFWEventHandleResult ret; InventTable inventTable; ; // Button OK Pressen? if(this.getBtnOk().isSubmitTarget(_submitTargetId)) { // find the item in the database inventTable = InventTable::find(this.getMain().varItemId()); if(!inventTable) // no data found throw error ("unknown item!"); // store name of found item in variable this.getMain().varItemName(inventTable.itemName); } ret = super(_submitTargetID); return ret; }
31
Your new menu item shows up on the bottom. Change the line number to move it up or down.
The name of the item should show up (or an error message if the item id you entered wasnt valid).
32
Event sent by the portal (logon, key press, etc.). Response from the framework.
Contents of the AX info log after handling the event. Here, youll find all transactions send to the framework by the Portal, and the response from the framework. Also displayed here are the contents of the info log at the end of event handling. Often, when your application is behaving erratic, youll find an answer here. For instance:
33
34
Next, perform the action in the application, so itll execute the bit of code with the throw error in it.
Go back to your code, remove the throw, set a breakpoint, save and compile
35
Next, press the button Debug Transaction. If AX is set up correctly for debugging code, the debugger will pop up. The run button will take you to your breakpoint.
36
37
On this form, well display a grid with all the items, where the user can select an item.
38
Select the ListItems form and add a data grid control named GridItems (leave it as it is for now) and a horizontal line (refer to the previous hands-on sections if youre unsure how to do this). Then, add a button control called BtnBack.
Set this so the OK button selects data from the grid. Finally, select the form ListItems, and set the default button to BtnOK.
39
This method is used to populate the grid with data. It fills a list with structs, where each struct represents a line of data to be displayed in the grid. Finally, the list is packed and returned. Next, well add a call to the method we just created, so override the onLoad method of the class HelloWorldListItems, and add a call to the fillFromList method of the grid, passing the packed list object created by the qryItems method, to populate the grid.
public D2MFWEventHandleResult onLoad() { D2MFWEventHandleResult ret; ret = super(); this.getGridItems().fillFromList(this.qryItems()); return ret; }
Here, the packed list from our first method is passed to the .fillFromList method that is unique to data grids. Upon entering the form, the data grid will now be populated by data from the invent table. Next, well set up the data to display.
40
On the Grid configuration (which only appears when you select a grid control), create the column mappings as shown here.
When a button with Data Grid Select is pressed, this variable is filled.
Please make sure the texts in the Query result list mapping column matches the names of the fields in the structs we created in the qryItems method. Also, if you decided to skip creating a horizontal line a couple of steps back, make sure you check the Append newline property on the data grid as shown below, otherwise the buttons will show up to the right of it instead of under it.
41
Also, remove the append newline on the TxtItemId textbox so the button sits directly to the right of it.
42
After pressing OK, the item is selected. If you are up for an extra challenge, you may want to try to display the ItemGroupId field in the data grid, and if youre feeling up to it, maybe add the current stock level of the item to the grid, too.
43
9.1.4 FindLabel
Use this method to quickly find a (DAW) label (without having to provide the device type id and language id).
9.1.5 GetDeviceTypeId
Gets the device type id for this session.
9.1.7 GetLanguageId
Returns the language id of the current language for this session.
9.1.9 Logoff
Logs off the current application. When calling from an event method, return the return value of this method to properly log off.
44
9.1.10 ReturnFromForm
Deactivates the current active form, and set the top form on the form stack as the new current form. This is the same as the return from form button actions. It takes a parameter that is passed to a call to the previous forms onReactivate event method as _returnResult.
9.1.12 ShowMainMenu
Returns the application to the main menu. When calling from an event method, return the return value of this method to properly return to the main menu.
45
9.2.7 IsReturnedFromForm
This method takes the _returnedFromFormId parameter passed to the onReactivate event method, and returns true if it matches the forms instance id.
9.2.8 PerformButtonNavigation
Performs the navigation action associated with a button on the form. Use this when you want to perform the navigation action associated with another button, but not the business logic in onSubmit. Important: when calling this from another event method, make sure you return the value returned by this function when you exit the event method. If you call the onSubmit of the form like this, dont call super as this might interfere with the navigation performed by the PerformButtonNavigation method.
9.2.9 ReturnFromForm
Deactivates the current active form, and set the top form on the form stack as the new current form. This is the same as the return from form button actions. It takes a parameter that is passed to a call to the previous forms onReactivate event method as _returnResult. Please note this method closes the current active form, which might not be the form that the calling class is linked to.
9.2.10 ShowForm
Shows the form, making it the new current form. This is the same as setting the showform button action. Leaving the _returnToExisting parameter false, the current active form is placed on the form stack, and the new form is instantiated if needed, and set to the new current form. If the _returnToExisting parameter is set to true, and the new form is already somewhere in the form stack, the forms above it on the stack are removed and the form is set active. If the form is not already in the stack, the system behaves just as if the parameter was left false.
46
9.3.13 Text
This getter/setter allows the developer to evaluate or set the text value of a control. For text controls, setting this property also sets the linked variable if any.
47
48
Now, after the user selects an item from the list of items and presses the OK button, the business logic that goes with submitting a press of the OK button on the ScanItemId form is executed. Remember, we set the button action property of the OK button to return from form (OK), and that is what we are checking in this bit of code by comparing it with D2MFWFormResult::OK. You can now check your changes. Note that after you select an item from the list and press the OK button, the application goes straight to the form displaying the item name. Also note, if you exit the list form by pressing cancel, you simply return to the item id input form. This same method could also be used to react to a user response to a form that offers a yes/no, or ok/cancel kind of dialog window.
49
Logged Employee.
Log-on date/time .
Detected browser.
Device IP addresses.
To access the framework parameters, go to the option DAW Framework from the main menu, and select Active Sessions.
50
Enables the option to transfer a session from one device to another. Checks to transfer a session to another device automatically (otherwise, an operator sets this manually on the Active Sessions form). Sessions will timeout when inactive. Inactivity timeout period. Number sequences used by the framework. Refer to the Installation guide for a description on how to set them up.
51
12. Notes
52