Tuesday 10 February 2015

Create a Query in Axapta

Query is the most widely used AOT object in Dynamics AX customization and development. After creation it can be used as a data source in the following AOT objects: -

  • Forms
  • DataSets
  • Reports
  • Views
To create a query, follow the following steps: -

  1. In AOT select Queries node, right click and select "New Query" command. This creates a new query sub-node under the Queries node.
  2. By default "Query1" is the name of your new query. To change its name, go to properties window and change the value in the "Name" property. OR press F2 when query is selected, now you can directly write its name on the node. For example write its name as "AxdLedgerJournal".

Sunday 8 February 2015

Dynamics AX form requires an active buffer

At the start of my Dynamics AX development learning, I received the error "Dynamics AX form requires an active buffer" many times whenever I tried to open a second level of form (child form). The reason is that I was not submitting the required parameter values for it.

To open second level of form, you have to mention the name of the caller form (parent form). The best example is Production Order's Picking List form. To open the "Production Journal Lines" sub-form within Picking List form, first create the Picking List form instance and open it, next create the "Production Journal Lines" form instance and set the "Caller" property with Picking List form instance.

Here is the code for above explanation: -

        Args                    argsForm;
        FormRun             formRun;
        FormRun             subformRun;
        ;
     

Tuesday 20 January 2015

Get control and control value in Dynamics AX form

With Dynamics AX 2012, accessing form's controls and their values is not very difficult, like in previous versions. You can access control object in code behind either dynamically as well as statically.

If you have a StringEdit control on your form with name "StringEdit_ShiftCode", you can access it through code in the following way: -


//define name for the control 
#define.ctrlShiftCode('StringEdit_ShiftCode')
//declare and define control.
FormStringControl shiftCode = this.form().design().control(#ctrlShiftCode);
Now you can get every property and methods for this control, like, shiftCode.text().

This is good if you have a dynamics form and controls. But if you have a static form then you can get the form's controls directly by names. For example, if you have a StringEdit control with name "StringEdit_ShiftCode" then change this control's AutoDeclaration property to 'Yes'. Now you can access this control's properties directly by specifying its name.Here is its example: -
str shiftCodeValue = StringEdit_ShiftCode.text();
 
 
 

Wednesday 9 May 2012

Creating Image Button in Silverlight

In the default list of controls comes with Silverlight 4 or 5, there is no such control like Image Button. But the creation of this control is very easy. Lets start to create Image Button.

Steps: -
1) Create a Silverlight User Control in your Silverlight project. Change its type to Button. I have given the XAML and C# code below.
XAML Code:

<Button x:Class="KnowledgeWeb.Assets.ImageButton"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    d:DesignHeight="80" d:DesignWidth="80">
    
    <Grid x:Name="LayoutRoot" Background="White">
 
    </Grid>
</Button>


C# Code:

namespace KnowledgeWeb.Assets
{
    public partial class ImageButton : Button
    {
        public ImageButton()
        {
            InitializeComponent();
        }
    }
}


2) Now to show an image on the button we have to edit the default template of the button class and then inserts the Image control in it.