Wednesday, November 18, 2015

Creating MenuSuites for the Microsoft Dynamics NAV Windows Client

MenuSuites display menus on the Departments page in the Microsoft Dynamics NAV Windows client. MenuSuites contain links that enable you to browse application or objects, and make the applications or objects easier to access in the Microsoft Dynamics NAV Windows client. A MenuSuite contains a set of menus that enable you to access reports, pages, codeunits, and so on, from the Microsoft Dynamics NAV Windows client.
Microsoft Dynamics NAV 2015 provides a basic MenuSuite that you can modify, or you can create new MenuSuites from the basic MenuSuite. You create MenuSuites in Object Designer and modify them in Navigation Pane Designer. This article demonstrates how to create a MenuSuite from the basic Menusuite for the Microsoft Dynamics NAV Windows client. For information about how to modify MenuSuites.
About This Article
This article shows you how to create a MenuSuite and modify department menus and menu items. This article illustrates the following tasks:
  • Creating a MenuSuite.
  • Adding a new department to the Departments page.
  • Modifying a department menu.
  • Modifying menu items in a department.
Prerequisites
To complete this article, you will need:
  • Microsoft Dynamics NAV 2015 installed with a developer license. 
  • The CRONUS International Ltd. demonstration database.
Story
Simon is a Microsoft Certified Partner working for CRONUS International Ltd. The company has recently reorganized. The Financial Management department has been converted to Accounting department and some of the menu items in the department will no longer be needed in the new Accounting department. The Human Resources department is no longer needed because the functions of that department have been contracted out to an agency. The functions of the Services department have been suspended because the department will closed until further notice. A new Customer Support department has been created at CRONUS International Ltd.. This new department will contain customer and vendor support information, including pages and reports.
Simon has been asked to perform the following tasks and create a MenuSuite that meets the following requirements:
  • Create a new department named Customer Support. This department should contain customer and vendor information such as a Customer Card page, Vendor List page, and Customer-Order Summary report. The information will be grouped under vendor and customer submenus. The List page should be accessed from the Lists category and the card page should be accessed from the Tasks subcategory. 
  • Add customer reports to the Reports and Analysis submenu The MenuSuite should contain the Customer-Order Summary report, which should be accessed from the Reports and Analysis subcategory in the Customer Support department. 
  • Remove departments and menu items that are no longer needed.
  • Modify the MenuSuite to reflect all the changes at have been made at CRONUS International Ltd.
Simon knows that he can create a MenuSuite in Object Designer and make the changes in Navigation Pane Designer to accomplish his task.
Creating the MenuSuite
You create MenuSuites from the basic MenuSuite that is provided in Microsoft Dynamics NAV and design it in Navigation Pane Designer. To create a new MenuSuite, choose a design level that your license allows. For this article, you will design the MenuSuite at the Dept-Partner design level. For more information about design permission levels.
To create the MenuSuite
1.     In the Microsoft Dynamics NAV Development Environment, choose Tools and then choose Object Designer.
2.     In Object Designer, choose MenuSuite and then choose New. The Design Level window is displayed.
The following image shows the MenuSuite design levels that are available in Microsoft Dynamics NAV.

3.     In the Design Level window, choose Dept - Partner and then choose OK to open Navigation Pane Designer.
The design level that you selected is shown in the header section of Navigation Pane Designer.
4.     Right-click the Navigation Pane Designer header and then choose Close Navigation Pane Designer.
5.     In the Save Changes dialog box, verify that Compile is selected and then choose Yes.
The MenuSuite that you created has an ID 1080, which is the ID for MenuSuites that are designed at the Partner level.
Adding a New Department
The next step is to create a menu for the new Customer Support department. You will make changes to the department menu and add menu items later.
To add a department
1.     In Object Designer, choose the MenuSuite that you just created and then choose Design.
2.     In Navigation Pane Designer, right-click the department tabs section and then choose Create Menu.
3.     In the Create Menu window, in the Caption text box, enter Customer Support. This is name of the new department.
4.     In the CaptionML text box, choose the EditAssist button to open the Multilanguage Editor.
Note
By default, the language setting on your computer is used for CaptionML, so clicking the text box automatically enters the defaults values.
5.     In the Multilanguage Editor window, verify that Language is set to English (United States) and Value is set to Customer Support, and then choose the OK button. You can change the language in the Windows Language List window by choosing the up arrow in the Language column.
6.     In the Bitmap text box, enter 10 and then choose OK. The Customer Support department menu is added to the MenuSuite. Valid bitmap numbers are 0-15. This is the bitmap that is displayed on the department menu in Navigation pane. However, the icons that are displayed on the departments on the Microsoft Dynamics NAV Windows client are different.
Modifying the Department Menus
Next, you will make the changes that were requested in the department menus. First, you will change the Financial Management menu to Accounting. You will also make changes to the menu items in the departments. You will delete the Human Resources department and hide the Services department. Simon knows that he may need the Services department in the future so he will hide it for now.
To modify the department menus
1.     In Navigation Pane Designer, select the Financial Management menu, from the shortcut menu, choose Properties.
2.     In the Menu Properties window, in the Caption text box, change the text to Accounting and then choose the OK button.
3.     Select the Human Resources menu, and from the shortcut menu, choose Delete.
4.     In the dialog box that opens, choose Yes. This removes this department from the MenuSuite.
5.     Select the Services department menu. From the shortcut menu, choose Hide in Designer. This removes it from the list but is not deleted.
6.     Select the Customer Support department menu. From the shortcut menu, choose Move Up. Move Customer Support below Accounting.
Modifying the Menu Items in a Department
You will now modify the menu items in the Accounting department and add menu items to the Customer Support department.
To modify the menu items
1.     Select the Accounting department and notice the menu items that appear in the top half of Navigation Pane Designer.
2.     Select the Periodic Activities group folder. From the shortcut menu, choose Properties to open the Group Properties window.
3.     Clear the Department Page check box and then choose OK. This removes the Periodic Activities group folder from the department page in the Microsoft Dynamics NAV Windows client.
4.     Select the Cash Management group folder. From the shortcut menu, choose Delete. This removes the folder and all menu items that are in it.
5.     Select the Customer Support department you created earlier. Notice that it does not contain any menu items or group folders.
6.     Right-click the menu items section, choose Create Group, and then name the folder Customers. You will add pages that are related to customers in this group.
7.     Expand the Customer folder node, right-click [Empty Group], and then choose Create Item to open the Create Item window.
8.     In the Object Type list, choose the drop-down arrow, and then select Page.
9.     In the Object ID text box, choose the up arrow to open the Page List window and then choose Customer Card (21) and then choose OK.
10.   Accept the defaults values for the Caption and CaptionML text boxes.
11.   In the Department list box, select Tasks and then choose the OK button. This puts this menu item in the Tasks sub menu.
12.   In the Create Item window, choose the OK button.
13.   Right-click the Customer Card menu item that you just created and then choose Create Item to open the Create Item window.
14.   Repeat steps 8 through 12 and set the following values in the Create Item window to add the Customer List (22) Page.
Object Type
Page.
Object ID
Customer List.
Caption
Customer List.
CaptionML
ENU=Customer List.
Department
Lists.
This puts this menu item in the Lists sub category.
15.   Right-click the menu items section, choose Create Group and then name the folder Vendors. You will add pages that are relate to vendors in this group.
16.   Expand the Vendors group folder node, right-click [Empty Group], and choose Create Item to open the Create Item window.
17.   Repeat steps 8 through 12 and set the following values in the Create Item window to add the Vendor Card (26) page.
Object Type
Page.
Object ID
Vendor Card.
Caption
Vendor Card.
CaptionML
ENU=Vendor Card.
Department
Tasks.
This puts this menu item in the Tasks sub category.
18.   Right-click the Vendor Card menu item you just added and then choose Create Item… to open the Create Item window.
19.   Repeat steps 8 through 12 and set the following values in the Create Item window to add the Vendor List (27) pages.
Object Type
Page.
Object ID
Vendor List.
Caption
Vendor List.
CaptionML
ENU=Vendor List.
Department
Lists.
This puts this menu item in the Lists sub category.
20.   Right-click Vendors and then choose Create Item… to open the Create Item window.
21.   Repeat steps 8 through 12 and set the following values in the Create Item window to add the Customer-Order Summary (107) report.
Object Type
Report.
Object ID
Customer-Order Summary.


Caption
Customer-Order Summary.
CaptionML
ENU=Customer-Order Summary.
Department
Reports and Analysis.
This puts this menu item in the Reports and Analysis sub category.
22.   If the item you want to create already exists, instead of creating a new one you can just insert the existing item.
23.   You have made all the changes that were requested. You will now save the MenuSuite and run it.
24.   The following image shows the departments and menu items in the Customer Support department in Navigation Pane Designer. The MenuSuite you have created in Navigation Pane Designer is similar to this image.


25.   Right-click the Navigation Pane Designer header and choose Close Navigation Pane Designer to save the MenuSuite. Notice the ID and the name of the MenuSuite you are saving. The ID and the name are given by Microsoft Dynamics NAV.
26.   In the Save Changes dialog box, verify that Compile is selected and then choose the OK button.


Running and Testing the MenuSuite
MenuSuites cannot be run directly in the development environment. You run MenuSuites in the Microsoft Dynamics NAV Windows client. In the Microsoft Dynamics NAV Windows client, menus are located under Departments and the submenus under the departments. Menus can be selected by department or by category.
To run and test the MenuSuite
1.     Open the Microsoft Dynamics NAV Windows client.
http://help.lsnav80.lsretail.com/help/local/note.gifNote
If the Microsoft Dynamics NAV Windows client is already open, you must close it and reopen it. Otherwise, the MenuSuite that you created will be displayed.
2.     In the leftmost pane, choose Departments.
3.     Verify that the Customer Support department and all the changes that you made appear in the Microsoft Dynamics NAV Windows client.

References: MSDN Blogs
_______________________________________

Tuesday, November 17, 2015

Importing Records From Excel Into Table Object in MS Dynamics NAV 2013 R2 (or) NAV 2015

Steps for Importing Records From Excel Into Table Object in MS Dynamics NAV 2013 R2
--------------------------------------------------------------------------------------------------------------

STEP - 1:
CREATE a new Report with Blank DataItem (or) With DataItem (e.g Customer), In My Demo I used Blank DataItem.
Properties : Value
------------------------
ProcessingOnly Yes
-----------------------
STEP - 2:
Create Globals Variables. [ Hint : View -> C/AL GLOBALS ]
VAriable_Name DataType SubType Length
-----------------------------------------------
CustomerDemo Record 50000 [Note : 50000 Is a "Customer Demo Table"
Excelbuffer Recoed 370
ServerFileName Text 50
SheetName Text 50
ImportFromExcel Boolean
RecNo Integer
NoOfRowsSkip Integer
i Integer
----------------------------------------------
Create Globals Constant Variables.
-------------------------
Name ConstValue
Text000 %1 table has been successfully updated with %2 Records.
Text001 Select (or) Import Excel File
ExcelFileExtensionOk .xlsx
----------------------------------------------
STEP - 3:
Design RequestPage (Follow By [VIEW -> Request Page])
------------------------------------------------------
Expanded Type SubType SourceExpr Name Caption
----------------------------------------------------------------------------------------
1 Container ContentArea RequestPage <RequestPage>
1 Group Group Options <Options>
0 Field ImporFromExcel ImportFromExcel Import From Excel
------------------------------------------------------------------------------------------------
STEP - 3:
OPEN the C/AL Editor { Note: Press F9 - on Request Options Page Designer, Only. }
---------------------------------------------------------------------------------
Create Local Variables. [ Hint : View -> C/AL LOCAL ]
-----------------------------------------------------
Name DataType Subtype Length
-----------------------------------------------------
FileMgt Codeunit 419 - File Management
Answer Boolean
------------------------------------------------------
STEP - 4:
Write Code on the Following Trigger:

######## Start ############[Trigers]###############

OnQueryClosePage(CloseAction : Action None) : Boolean
// Code Start

IF ImportFromExcel THEN
  BEGIN
    IF CloseAction = ACTION::OK THEN // Validation For OK Button.
      BEGIN
        ServerFileName := FileMgt.UploadFile(Text001,ExcelFileExtensionOk);
        IF ServerFileName = '' THEN
          EXIT(FALSE);

        SheetName := ExcelBuffer.SelectSheetsName(ServerFileName);
        IF SheetName = '' THEN
          EXIT(FALSE);
      END;
  END;
IF CloseAction = ACTION::Cancel THEN  // Validation For Cancel Button.
  BEGIN
    Answer := CONFIRM('Are you sure want to Cancel?');
    IF Answer THEN
      EXIT(TRUE)
    ELSE
      EXIT(FALSE)
  END;
IF ImportFromExcel = FALSE THEN // Validation For CheckBox.
  BEGIN
    Answer := CONFIRM('You did not select ImportFromExport Check Box.\ If You Click Yes Then You Will Exit From Importing UI.');
    IF Answer THEN
      EXIT(TRUE)
    ELSE
      EXIT(FALSE)
  END;
// Code End

######## END ############[Trigers]###############

STEP - 5:
SELECT Report DataSet Designer [Thru.- Window -> [# Report #ID ImportFromExcel - Report Dataset Designer.
------------------------------------------------------------------------------------------------
OPEN the C/AL CODE [ Hint. View -> C/AL Code, (or) F9]
-------------------------------------------------------
Step - 6:
WRITE the Following Code on respective Trigers.
--------------------------------------------------------
######## Start ############[Trigers]###############

----------------------------------
OnInitReport()
ImportFromExcel := TRUE;
-----------------------------------

OnPreReport()
ImportExcelData() // User Define Function

-------------------------------------------------------------------

OnPostReport()

IF ImportFromExcel THEN
  BEGIN
    ExcelBuffer.DELETEALL;
    IF i > 0 THEN
      MESSAGE(Text000,CustomerDemo.TABLECAPTION,(i-NoOfRowsSkip));
  END;
-----------------------------------------

########### END ##########[Trigers]###############

------------------------------------------------------------------------
######################## My Function #############

ImportExcelData()

// Code for Importing Records From Excel to NAV Table

IF ImportFromExcel THEN
  BEGIN
    CustomerDemo.DELETEALL;
    ExcelBuffer.LOCKTABLE;
    CustomerDemo.LOCKTABLE;
    CustomerDemo.INIT;
    NoOfRowsSkip := 5;  // Bcoz I have planned to skip First 5 Rows/Records.
    i := NoOfRowsSkip;
    ExcelBuffer.OpenBook(ServerFileName,SheetName);
    ExcelBuffer.ReadSheet;
    IF ExcelBuffer.FINDFIRST THEN
      REPEAT
        IF (ExcelBuffer."Row No." = i) AND (ExcelBuffer."Column No." = 1) THEN
          CustomerDemo."No." := ExcelBuffer."Cell Value as Text";
        IF (ExcelBuffer."Row No." = i) AND (ExcelBuffer."Column No." = 2) THEN
            CustomerDemo.Name := ExcelBuffer."Cell Value as Text";
        IF (ExcelBuffer."Row No." = i) AND (ExcelBuffer."Column No." = 3) THEN
          CustomerDemo.Address := ExcelBuffer."Cell Value as Text";
        IF (ExcelBuffer."Row No." = i) AND (ExcelBuffer."Column No." = 4) THEN
          EVALUATE(CustomerDemo."Balance (LCY)", ExcelBuffer."Cell Value as Text");

        IF (ExcelBuffer."Row No." = i) AND (ExcelBuffer."Column No." = 4) THEN BEGIN
          CustomerDemo.INSERT;
          i += 1;
        END;
     UNTIL ExcelBuffer.NEXT = 0 ;
 END;

// End Code

-------------------------------------------------------------------------

############### END Function #############################
STEP - 7:
SAVE, COMPILE And RUN.....
-----------------------------------------------
Thanks & Best Regards
Binesh Singh Rajput
(MCP, MS, MCTS)
----------------------------------------------


##########################################################

Popular Posts