Working with customized AIF (Service Operation : Create)

//Service Declaration
ContactQueryServiceClient _client = new ContactQueryServiceClient();
AxdContactQuery mycontactQuery = new AxdContactQuery();
AxdEntity_ContactTable trans = new AxdEntity_ContactTable();

//trans.MyContactIDSpecified = true;
trans.ContactEmail = “”;
trans.ContactID = “CNT-0005”;
trans.ContactName = “Ahmed Alam”;
trans.ContactMobile = “0535865xxx”;

mycontactQuery.ContactTable = new AxdEntity_ContactTable[1] { trans };
_client.create(this.getCallContext(), mycontactQuery);
RTB_ErrorBox.Text = “Inserted successfully.”;
catch (Exception ex)
RTB_ErrorBox.Text = Convert.ToString(ex.Message);

Checklist for customized workflow AX 2012

1.      Workflow configuration

Should defined the batch group within AX 2012.
Should configured workflow infrastructure configuration.
Should defined workflow user id for the “System Service Account”

2.      Customization: Phase I

Workflow category should be created.
Required query has been created with dynamic property should be “True/Yes”
Base Enumerator must be created.
Addition upper define type of enumerator within the required table.
“CanSubmitToWorkflow” method must be defined.
Display type menu should be created to set the properties of the following caetgories.

–           EnumTypeParameter [e.g. ModuleAxapta]

–           EnumParameter [e.g. SalesOrder]


“Workflow Type” must be created with the help of “Workflow Type Wizard”.
System will generate one “Private” project with few classes, display menu items and workflow type.
On the designated “Form” workflow should be enabled and its associated properties should be defined properly.
Code snippet should be there for “Submit” within the “*SubmitManager” class.
Code snippet should be there as per requirement within the “*EventHandler” class.

–           Cancelled

–           Completed

–           Returned etc.

Rename both the wizard generated menus within this project.


Create a “Workflow Approval” through “Workflow Approval Wizard”.
System will generate one “Private” project with few classes, display menu items and workflow approval.
Drag the approval element to the “Workflow Type > Supported Element”.
Code snippet should be there as per requirement within the “*EventHandler” class.

–           Cancelled

–           Completed

–           Returned etc.

Rename the display menu item.


Drag the “Display Menu” into the “Menu” from the AOT which was created in phase I.
Desired workflow should be configured/created.
Test the workflow within the required module.

Compile AX 2012 R2 or later through command prompt

We can compile the Microsoft Dynamics AX 2012 R2 or later even through command prompt and it will take comparatively less time than GUI mode.

Server file location:

– D:\Program Files\Microsoft Dynamics AX\60\Server\MicrosoftDynamicsAX\bin

On command prompt:

axbuild.exe xppcompileall /s=01 /altbin=”C:\Program Files (x86)\Microsoft Dynamics AX\60\Client\Bin” /log:”C:\Temp”

Creating Customer/Vendor Ledger Dimension

/// <summary>
/// To get the Ledger Dimension Value [RecId] for all listed items in LedgerJournalACType
/// </summary>
/// <param name=”_CustVendAccountId”>
/// Must provide the CustID or VendID
/// </param>
/// <param name=”_accountType”>
/// Must define the Ledger Journal Account Type
/// </param>
/// <returns>
/// Record ID
/// </returns>
/// <remarks>
/// </remarks>

public static LedgerDimensionAccount getDynamicLedgerDimension(str _CustVendAccountId, LedgerJournalACType _accountType)
LedgerDimensionAccount _ledgerDim;

_ledgerDim = DimensionStorage::getDynamicAccount(_CustVendAccountId, _accountType);

return _ledgerDim;

Creating Dimension Attribute Value Set ID

//Code written by Ahmed Alam on 19th Dec, 2012
//ReasonCode: To save the dimension value from container variable and return the RecId
private static recId getDimensionAttributeValueSetId(container _dimensionValue, dataAreaId _dataAreaId = curext())
recId dimensionId;
DimensionAttributeValueSetStorage storage;
DimensionAttribute dimensionAttribute;
DimensionAttributeValue dimensionAttributeValue;
int attributeCount, attributeIndex;
str attributeName, attributeValue;
int containerElementIndex, counter;

containerElementIndex = 1;

storage = new DimensionAttributeValueSetStorage();
for(Counter = 1; counter <= conLen(_dimensionValue); counter+= 3)
// Get attribute count
attributeCount = conPeek(_dimensionValue, containerElementIndex);

// Get attribute name
attributeName = conPeek(_dimensionValue, containerElementIndex);

// Validate the Financial Dimenion that was passed in.
dimensionAttribute = AxdDimensionUtil::validateFinancialDimension(attributeName);

// Get attribute value
attributeValue = conPeek(_dimensionValue, containerElementIndex);

// Validate the Financial Dimenion Value that was passed in.
dimensionAttributeValue = AxdDimensionUtil::validateFinancialDimensionValue(dimensionAttribute, attributeValue);

// Add attribute
dimensionId =;

return dimensionId;

Creating Default Dimension

//Code added by Ahmed Alam on 6th Oct, 2013
//ReasonCode: User can get the specific dimension value on the basis of provided Financial Dimension
public static RecId createDefaultDimension(container defaultDim, container dimValue)
container ledgerDimension;
DimensionDefault DimensionDefault;
int _counter;
DimensionValue _foundValue[];
Name _foundName[];
Struct struct;

struct = new Struct();
for(_counter = 1; _counter <= conLen(defaultDim); _counter++)
_foundValue[_counter] = conPeek(defaultDim, _counter);
_foundName[_counter] = conPeek(dimValue, _counter);
struct.add(_foundName[_counter], _foundValue[_counter]);

ledgerDimension += struct.fields();
ledgerDimension += struct.fieldName(_counter);
ledgerDimension += struct.valueIndex(_counter);

DimensionDefault = Dimensions::getDimensionAttributeValueSetId(ledgerDimension);
return DimensionDefault;

Upload Inventory Movement Journal through code in AX 2012 R2

To upload the inventory movement journal, kindly follow the below steps.

1- In Inventory Movement Journal main form, create a journal with Opening Balance.

2- Have the journal number and create the csv file for the Inventory Movement Journal Lines.

Note: how to read the data from csv file :


How to retrieve multiple selected records from the Grid through X++ in AX 2012

    int                recordsCount;
    SalesLine    salesline;
    recordsCount = salesline_ds.recordsMarked().lastIndex();  // Total no of marked records.
    salesline = salesline_ds.getFirst(1);
    while (salesline)
         info(strFmt(“%1 : %2”,_salesLine.ItemId, _salesLine.LineNum));
        salesline = salesline_ds.getNext();