Tuesday, January 21, 2014

Microsoft Dynamics AX 2012 Model Export/Import 


To Import/Export use Powershell or Cmd Prompt  

Powershell:

Start-->Administrative tools --> Microsoft dynamics Ax 2012 Managementshell

Export:

Export Command Syntax :

Export-AXModel –Model <name> -File <Filename.axmodel>


Example :
Export-AXModel –Model dev1-File C:\Dev1.axmodel

Import:

Import Command Syntax :

Install-AXModel -File <Filename.axmodel> -Details

Exmaple :

Install-AXModel -File C:\Dev1.axmodel -Details

Import Error

One or more conflicting model elements already exist in an installed model








Solution
open cmd prompt 
paste the command to import the model file........

axUtil import /file:"C:\Dev1.axmodel" /conflict:Push

Wednesday, January 8, 2014

Retrieving multiple selected records from Grid using X++.

In this post, we discuss how we can retrieve all selected(marked) records of a datasource or retrieve marked records form Grid.
For this purpose follow the steps listed below.
  1. Create a new table named "Student" that contains two string fields i.e. Name & ID.
  2. Create a new form and add the newly created "Student" table in the datasource node.
  3. Next create a new button on the form, set its multiselect property to "Yes" . Now override the clicked method of the button and add the following code.
Code snippet

    int             recordsCount;
    Student     studentLocal;
    super();
    
    recordsCount = student_ds.recordsMarked().lastIndex();  // Total number of marked records.
    studentLocal = student_ds.getFirst(1);
    
    while (studentLocal)
    {
        info(studentLocal.Name +" " +studentLocal.ID);
        studentLocal = student_ds.getNext();
    }

Hide selected enum values in form control using X++ code

Removing some of the elements that are not needed when they are shown in a combo-box on a form.To achieve this behavior Microsoft has given a class just for that purpose. The class is “SysFormEnumComboBox”.

Here is a sample code snippet that depicts how to use this class on a form having a combo-box control: 

Simply override the init() of the form and add the code.

public void init()
{
    SysFormEnumComboBox     sysFormEnumComboBox;
    Set enumSet = new Set(Types::Enum); // collection of selected values.
 
    enumSet.add(HMDaysName::Monday);
    enumSet.add(HMDaysName::Wednesday);
    enumSet.add(HMDaysName::Friday);
    

  SysFormEnumComboBox = SysFormEnumComboBox::newParameters(element,                                                 element.controlId(formControlStr(TestForm, ComboBoxCtrl)),  enumName2Id(enumStr(HMDaysName)), enumSet,"Select");
    

    super();
    SysFormEnumComboBox.select(HMDaysName::Friday); // To select value in combo
}