AXForum  
Вернуться   AXForum > Microsoft Dynamics AX > DAX Blogs
All
Забыли пароль?
Зарегистрироваться Правила Справка Пользователи Сообщения за день Поиск

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 28.10.2006, 18:22   #1  
Blog bot is offline
Blog bot
Участник
 
25,617 / 848 (80) +++++++
Регистрация: 28.10.2006
Axapta Lessons: FORM SalesTable (3): Add a document to the button Posting
Источник: http://axapta-lessons-learned.blogsp...cument-to.html
==============
Analyze the design of the sales order form to identify the changes required

We are now going to look at how the document Quotation is implemented. Our investigation comprises two steps, investigation of the Design of the Form and investigation of the Design of the Document.

During the walkthrough we will identify the components we need to develop.

A bit of explanation is sometimes provided to understand why a component is needed and how things are done.

1. Investigate the Design of the form

Open the AOT.
Locate and Open the node Forms.
Locate and Open the node SalesTable.
Open the node Designs.
Open the node Design and see the 3 groups: Table, CtrlSplitVerical and Line
Open the node [Group:Table] and Go to the node [ButtonGroup:ButtonsHeader].

The button group ButtonsHeader contains all the buttons seen on the right side of the sales order form. (Posting, Setup, and so on)
Open the node [MenuButton:ButtonHeaderUpdate].

This node corresponds to the Button Posting. If you are not sure check the property Text in the property sheet.

The MenuButton, as the name implies, contains form controls of type MenuItemButton. Compare it with a menu containing a list of menu items.

Select the MenuItemButton buttonUpdateQuotation.
Right-click and Open the property sheet.
Now notice the settings of the properties:
- Name
- AutoDeclaration
- MenuItemType
- MenuItemName
- DataSource

The properties Name and AutoDeclaration are related. When AutoDeclaration is set to yes the system declares a member variable with the same name as the form control, in this case buttonUpdateQuotation. As such it is easy to access the form control from X++ code, as we will see later is necessary.

The MenuItemType and MenuItemName are related.
Both determine which menu item is called when the button is clicked. Menu items of type Action hold items that activate queries or classes.

The MenuItemButton buttonUpdateQuotation contains the following property values:
- Name = buttonUpdateQuotation
- AutoDeclaration = Yes
- MenuItemType = Action
- MenuItemName = SalesFormLetter_Quotation
- DataSource = SalesTable

[Probably you wonder where the name of the menu item listed under the button Posting is coming from. Well check the property label on the menu item SalesFormLetter_Quotation.]


We will investigate how the menu item SalesFormLetter_Quotation is designed later.

We have now seen the different menu item buttons that are available under the button Posting, but how are these buttons enabled.

When a button is pushed the method clicked() on the button group ButtonsHeader is executed. This method calls the method enableUpdateJournalButtons() to enable/disable the menu item buttons according to some criteria. For example, when we have a sales order with status Delivered, the Quotation button is disabled.

Open the node Methods below the ButtonGroup ButtonsHeader.
Double-click the method clicked() to open the X++ editor.

We will see the method clicked() is calling the method enableUpdateJournalButtons() on the class SalesTableForm or at least on an object of type SalesTableForm. The member variable buttonUpdateQuotation is passed as a parameter. It is here we will have to add the member variable for our new document button.

The method enableUpdateJournalButtons() on the class SalesTableForm is responsible for determining whether a button can be updated or not.

The "enable status" of each menu item button is stored in the container checkIfupdate. The elements in the container are arranged in a structured order. Standard there are 7 documents. So there are also 7 elements in the container. Each element consists of boolean value, either true for enabled or false for disabled. The values are stored in the following order:
1 Quotation
2 Confirmation
3 PickingList
4 PackingSlip
5 Invoice
6 PickingListRegistration
7 ProjectPackingSlip

Where are these elements inserted into the container checkIfupdate?
Some will think we are making a huge jump here, but actually the container is build in the method checkIfUpdate() of the class SalesTableType.

Inside the method enableUpdateJournalButtons() the table method checkIfUpdate() is called to build the container. The statement for calling the method is: checkIfupdate = _salesTable.checkIfUpdate();

The method on the table SalesTable contains the code: return this.type().checkIfUpdate();
The method type() contains the code: return SalesTableType:construct(this). Yes this method is on the table SalesTable and its purpose is to create an object of a certain type! Once the object is created the method checkIfUpdate() can be executed.

The method construct() on the class SalesTableType returns an object of type SalesTableType_Sales, in case our order is a "sales order" identified by the field SalesType.
The object is returned through the method construct() on the class SalesTableType_Sales using the following code: return new SalesTableType_Sales(salesTable).

Now the type of the object is known, the last part of the code ".checkIfUpdate" is called from the class SalesTableType_Sales where it is inherited from the class SalesTableType.

It is this method that inserts the elements into the container. For example: the code: c = conIns(c, SalesTableType::posQuotation() , this.canQuotationBeUpdated(); adds the element for the document quotation.

The method checkIfUpdate() contains such a line of code for each document.

To avoid hardcoding, the index of each element is accessed via static methods. In this example the static method posQuotation() returns the value 1.

The boolean value of the element is determined using the methods canQuotationBeUpdated() and mayQuotationBeUpdated(). Each document has its own set of these methods.

The method mayQuotationBeUpdated() checks the order status of the sales order (field SalesStatus) and determines whether updating the Quotation is allowed.

We need the base enum DocumentStatus here, because these set of methods use it. Here we also need to add the method for returning the position of our document (posQuotation) and the two methods (canQuotationBeUpdated() and mayQuotationBeUpdated()) that determine whether the button is enabled.

The following code in the method enableUpdateJournalButtons()gets the status of the menu item button from the container: enableQuotationButton = conPeek(checkIfupdate, SalesTableType::posQuotation());

After the status is captured, then the button will be enabled/disabled by the code:
if (buttonUpdateQuotation)
buttonUpdateQuotation.enabled(enableQuotationButton);

Here we need to add code to handle our document, get the status of the menu item button from the container and enable/disable the menu item button.

Let us continue with the analysis of the menu item SalesFormLetter_Quotation and the layout of the document.





==============
Источник: http://axapta-lessons-learned.blogsp...cument-to.html
 

Похожие темы
Тема Автор Раздел Ответов Посл. сообщение
dax-lessons: Document Handling in AX - setup and Example Blog bot DAX Blogs 0 27.08.2007 23:00
Axapta Lessons: Trapping keystrokes in a Form Blog bot DAX Blogs 13 01.11.2006 18:16
Axapta Lessons: FORM SalesTable (4): Add a document to the button Posting Blog bot DAX Blogs 0 28.10.2006 18:22
Axapta Lessons: Add menu options to the Add-Ins submenu Blog bot DAX Blogs 0 28.10.2006 18:22
Говорят вышел SP2 для Axapta 3. Кто нибуть что знает на эту тему? soin DAX: Прочие вопросы 10 13.10.2003 10:43

Ваши права в разделе
Вы не можете создавать новые темы
Вы не можете отвечать в темах
Вы не можете прикреплять вложения
Вы не можете редактировать свои сообщения

BB коды Вкл.
Смайлы Вкл.
[IMG] код Вкл.
HTML код Выкл.
Быстрый переход

Рейтинг@Mail.ru
Часовой пояс GMT +3, время: 20:41.