다음을 통해 공유


How to: Create an Action Pane Button

Applies To: Microsoft Dynamics AX 2012 R3, Microsoft Dynamics AX 2012 R2, Microsoft Dynamics AX 2012 Feature Pack, Microsoft Dynamics AX 2012

A Microsoft Dynamics AX action pane button is a control that performs a specified action when it is clicked. The list page action pane displays buttons that represent each task and operation that the list page supports.

Before you add a button to a list page, the list page must have an action pane, action pane tab, and action pane button group. For more information about how to add an action pane to a list page, see Walkthrough: Creating a List Page and Adding an Action Pane.

The following procedures show how to use the AOT to create the following button types:

  • A command button that performs a Microsoft Dynamics AX command. In this procedure you will learn how to add a command button that deletes a record.

  • A menu item button that opens a task page in a new window.

  • A menu button that displays a list of buttons.

  • A button that executes custom code. In this procedure you will learn how to create a button that displays whether the list page can obtain records from more than one company.

Creating a Command Button

In this procedure, you will add a command button that deletes a record.

To add a command button

  1. In the AOT, expand Forms, and then expand the form node.

  2. To view the action pane, expand Designs, and then expand the Design node.

  3. Expand the action pane, expand the action pane tab, and expand the button group that will contain the new button. Right-click the button group control, click New Control, and then click CommandButton. A new button control is added to the button group.

  4. To specify the location of the button in the button group, use the ALT+UP ARROW or ALT+DOWN ARROW to position the button before or after an existing button.

  5. To view the button's properties, expand the button group, right-click the CommandButton node, and then click Properties. The button properties window opens and displays the default values. You can customize the button by replacing default property values with new values. For a command button, provide values for the following properties.

    Property

    Value

    Big

    Click Yes to make the button a large button.

    ButtonDisplay

    Specify how the button displays its text and image. For example, a large action pane button typically uses Text & Image above.

    Command

    Specify the command that you want the button to perform when it is clicked. For example, click Delete Record for a button that deletes a record.

    ForcedToOverflow

    Specify whether the button should always be in the button group overflow menu. Click Yes to add it to the overflow menu.

    ImageLocation

    Specify the location of the image that you want to appear on the button. You can click File, AOTResource, or EmbeddedResource.

    MultiSelect

    Click Yes to use the command when there is more than one highlighted record in the grid.

    Name

    Specify a name that uniquely identifies this button.

    NormalImage

    Specify the value that represents the image to display on the button. For example, use 10121 for a button that deletes a record.

    Primary

    Click Yes to keep the button displayed when the action pane size decrease.

    ShowShortCut

    No

    Text

    Specify the label to display on the button. For example, use Delete for a button that deletes a record.

  6. Right-click the form, and then click Save.

To view the command button, right-click the form in the AOT, and then click Open. The client displays the button in the list page action pane. To perform the specified command, click the button.

Creating a Menu Item Button

In this procedure, you will create a menu item button that opens a task page in a new window.

Before you create the button, verify that the menu item supports the client environment. The RunOn property of the menu item specifies where the action executes. The following table describes the RunOn setting for each type of menu item.

Menu item type

Description

Action

The default value for the RunOn property is Called from. For client actions, you can set RunOn to Called from, Server, or Client. For actions that open client forms or menu items, set the RunOn property to Client.

For actions that run on Enterprise Portal, set the RunOn property to Called from, or Server.

Display

You can use all values in the RunOn property.

Output

Set the value of the RunOn property to Client.

To create a menu item button

  1. In the AOT, expand Forms, and then expand the form node.

  2. To view the action pane, expand Designs, and then expand the Design node.

  3. Expand the action pane, expand the action pane tab, and expand the button group that will contain the new button. Right-click the button group control, click New Control, and then click MenuItemButton. A new button control is added to the button group in the AOT.

  4. To specify the location of the button in the button group, use the ALT+UP ARROW or ALT+DOWN ARROW to position the button before or after an existing button.

  5. To view the button's properties, expand the button group, right-click the MenuItemButton node, and then click Properties. The button properties window opens and displays the default values. You can customize the button by replacing default property values with new values. For a menu item button, provide values for the following properties.

    Property

    Value

    Big

    Click Yes to make the button a large button.

    ButtonDisplay

    Select the value that represents how you want the button to display its text and image values.

    ForcedToOverflow

    Specify whether the button should always be in the button group overflow menu. Click Yes to add it to the overflow menu. Click No to have the button display in the button group.

    ImageLocation

    Specify the location of the image that you want to appear on the button. You can click File, AOTResource, or EmbeddedResource.

    MenuItemName

    Specify the menu item that you want the button to use when it is clicked.

    MenuItemType

    To change the available MenuItemName list, select the type of the menu item that you want to use.

    MultiSelect

    Click Yes to use the command against more than one highlighted record in the grid.

    Name

    Specify a name that uniquely identifies this button.

    NormalImage

    Specify the value that represents the image to display on the button.

    Primary

    Click Yes to keep the button displayed when the action pane size decreases.

    ShowShortCut

    No

    Text

    Specify the label to display on the button. For example, use Delete for a button that deletes a record.

  6. Right-click the form, and then click Save.

To view the button, right-click the form name in the AOT, and then click Open. The client displays the button in the list page action pane. To open the specified menu item, click the button.

Creating a Menu Button

In this procedure, you will create a menu button that displays a list of buttons.

To create a menu button

  1. In the AOT, expand Forms, and then expand the form node.

  2. To view the action pane, expand Designs, and then expand the Design node.

  3. Expand the action pane, expand the action pane tab, and expand the button group that will contain the new button. Right-click the button group control, click New Control, and then click MenuButton. A new button control is added to the button group in the AOT.

  4. To specify the location of the button in the button group, use the ALT+UP ARROW or ALT+DOWN ARROW to position the button before or after an existing button.

  5. To view the button's properties, expand the button group, right-click the MenuButton node, and then click Properties. The button properties window opens and displays the default values. You can customize the button by replacing default property values with new values. For a menu button, provide values for the following properties.

    Property

    Value

    Big

    Click Yes to make the button appear as a large button in the action pane.

    ButtonDisplay

    Select the value that represents how you want the button to display its text and image values. A large action pane button typically uses Text & Image above.

    ForcedToOverflow

    Specify whether the button should always be in the button group overflow menu. Click Yes to add it to the overflow menu. Click No to have the button display in the button group.

    ImageLocation

    Specify the location of the image that you want to appear on the button. You can click File, AOTResource, or EmbeddedResource.

    Name

    Specify a name that uniquely identifies this button.

    NormalImage

    Specify the value that represents the image to display on the button.

    Primary

    Click Yes to keep the button displayed when the action pane size decreases.

    ShowShortCut

    No

    Text

    Specify the label to display on the button.

  6. To add buttons to the button list, right-click the button, click New Control, and then click the type of button.

    Note

    You can add a command button, menu item button, and button to the menu button list. After you add the button control, set the properties using the procedure for that button type.

  7. Right-click the form, and then click Save.

To view the menu button, right-click the form name in the AOT, and then click Open. The client displays the button in the list page action pane. To view the button list, click the button.

Creating a Button

In this procedure, you will create a button that displays whether the list page can obtain records from more than one company.

To create a button

  1. In the AOT, expand Forms, and then expand the form node.

  2. To view the action pane, expand Designs, and then expand the Design node.

  3. Expand the action pane, expand the action pane tab, and expand the button group that will contain the new button. Right-click the button group control, click New Control, and then click Button. A new button control is added to the button group in the AOT.

  4. To specify the location of the button in the button group, use the ALT+UP ARROW or ALT+DOWN ARROW to position the button before or after an existing button.

  5. To view the button's properties, expand the button group, right-click the Button node, and then click Properties. The button properties window opens and displays the default values. You can customize the button by replacing default property values with new values. For a button, provide values for the following properties.

    Property

    Value

    Big

    Click Yes to make the button appear as a large button in the action pane.

    ButtonDisplay

    Select the value that represents how you want the button to display its text and image values.

    ForcedToOverflow

    Specify whether the button should always be in the button group overflow menu. Click Yes to add it to the overflow menu. Click No to have the button display in the button group.

    ImageLocation

    Specify the location of the image that you want to appear on the button. You can click File, AOTResource, or EmbeddedResource.

    Name

    Specify a name that uniquely identifies this button.

    NormalImage

    Specify the value that represents the image to display on the button.

    Primary

    Click Yes to keep the button displayed when the action pane size decreases.

    ShowShortCut

    No

    Text

    Specify the label to display on the button.

  6. Expand this button node, right-click Override Method, and then click clicked.

  7. Right-click the clicked method and then click Edit. The AOT opens the code editor for the specified method. Add the code that you want to execute when the button is clicked. The code example that follows shows how to override the clicked method to display information about the form data source.

  8. Right-click the form, and then click Save.

To view the button, right-click the form name in the AOT, and then click Open. The client displays the button in the list page action pane. To test the button action, click the button.

The following code example shows how to override the clicked event. When the button is clicked, a dialog box opens and displays a message that states whether the list page displays data from a single company or from more than one company.

    void clicked()
    {
        // Declare variables
        Dialog dialogBox;
        boolean isCrossCompany;
        ;
    
        super();
        
        // Determine whether the form supports cross company queries.
        isCrossCompany = Form.dataSource(1).crossCompanyAutoQuery();
        
        // Create a dialog box object.
        dialogBox = new Dialog("Cross Company Status");
        
        // Notify the user whether the form displays data from 
        // more than one company.
        if(isCrossCompany == true)
        {
            dialogBox.addText("The form data source retrieves records
              from all companies.");
        }
        else
        {
            dialogBox.addText("The form data source retrieves records 
              from a single company.");
        }
        
        dialogBox.run();
    }

See also

Action Pane Button Overview

How to: Add an Image to an Action Pane Button

Announcements: New book: "Inside Microsoft Dynamics AX 2012 R3" now available. Get your copy at the MS Press Store.