Sunday, December 31

Microsoft Dynamics AX Overview

Microsoft Dynamics is a unique Business Solution provide by the Microsoft Team. The Microsoft Dynamics is totally an ERP (Enterprise Resources Panning) solution used by many companies and industries world wide. Dynamics AX is not just an ordinary software solution for any business solution, it's provide a compact, business oriented solution in which developer can develop out of the box business logic/requirements.


Microsoft Dynamics AX Modules
Dynamics AX is such a powerful tool which contains 19 CORE Modules in it.
Following are the list of the modules Dynamics AX contains according to it's versions:
Traditional core (since Axapta 2.5)
  • General Ledger – ledger, sales tax, currency, and fixed assets features
  • Bank Management – receives and pays cash
  • Customer Relationship Management (CRM) – business relations contact and maintenance (customers, vendors, and leads)
  • Accounts Receivable – order entry, shipping, and invoicing
  • Accounts Payable – purchase orders, goods received into inventory
  • Inventory Management – inventory management and valuation
  • Master Planning (resources) – purchase and production planning
  • Production – bills of materials, manufacturing tracking
  • Product Builder – product mode creation and maintenance
  • Human Resources – employee information
  • Project Accounting – projects creation and tracking (primarily from an accounting perspective)
  • Basic – data configuration
  • Administration Module – system configuration
  • Procurement and Sourcing
  • Sales and Marketing
  • Call Center - employees take orders over the phone and are able to create sales orders
  • General Ledger - the ability to transfer opening balances in balance sheet accounts to a new fiscal year
  • Inventory and Warehouse Management - compare item prices, enhanced posting routine and a new Inventory aging report
  • Master Planning - estimate future demand and create demand forecasts based on transaction history
  • Procurement and Sourcing - create your own solicitation request for RFQs, and more
  • Production Control - a new option to automate material reservations
  • Project Management and Accounting - new on-account billing rules and fee transactions that modify invoice proposal sales prices
  • Public Sector - now able to publish a request for quotation (RFQ) to the Vendor portal and now have the ability to view details of closed RFQs
  • Retail - commerce Data Exchange, updated retail server, new retail hardware station, and more
  • Sales and Marketing - register serial numbers during sales processes when preparing the packing slip or the sales order invoice
  • Transportation Management - plan transportation for inbound and outbound shipments, configure rating structures and view driver check-in and check-out history
  • Trade Allowance Management - define merchandising events, manage trade fund budgets, process customer payments (including deductions, and more
  • Warehouse Management - configure inbound and outbound intelligent workflows, use scanners/mobile devices to optimize precision in the picking and put-away processes, and more
Extended core
  • Shop Floor Control
  • Cost Accounting
  • Balanced Scorecards
  • Service Management
  • Expense Management
  • Payroll Management
  • Environmental Management
External components
  • Enterprise Portal for Dynamics AX (built on Sharepoint Services)
  • Microsoft SQL Reporting Services integration
  • Microsoft SQL Analysis services (KPIs)
  • Project Server Integration
  • WorkFlow
  • Application Integration Framework (Webservices + Biztalk adapter)
  • A .Net Business Connector for third-party software (A COM adapter is also available)
  • Microsoft Dynamics Mobile 1.5 development tools
  • Microsoft Project Client
  • Microsoft Excel
  • Microsoft Word
  • Office 365

Thursday, December 21

AX 2012 - Get default financial dimension values through X++ code

There are many areas in AX where "Default Financial Dimension" is used.In many cases we have to show the default financial dimension and its values in either forms or reports,so the key thing is that how do we get the default financial dimension and its value associated to a particular entity though X++ code.Here is the code snippet that will meet your needs.




    DimensionAttributeValueSetStorage    dimStorage;
    HcmPositionDefaultDimension          HcmPositionDefaultDimension;
    DimensionAttribute  DimensionAttribute;
    Counter                                               i;
    DimensionAttribute          dimAttr;
    DimensionAttributeValue     dimAttrValue;
    Common                      common;
    DictTable                   dictTable;
    str                         Name;
    str                         value;

    HcmPositionDefaultDimension = HcmPositionDefaultDimension::findByPositionLegalEntity(5637144830,CompanyInfo::find().RecId);

    dimStorage = DimensionAttributeValueSetStorage::find(HcmPositionDefaultDimension.DefaultDimension);

    for (i=1 ; i<= dimStorage.elements() ; i++)
    {
        select firstonly dimAttrValue
        where dimAttrValue.RecId == dimStorage.getValueByIndex(i)
        join dimAttr
            where dimAttr.RecId == dimAttrValue.DimensionAttribute;

        if (dimAttr && dimAttrValue)
        {
            dictTable = new DictTable(dimAttr.BackingEntityType);
            common = dictTable.makeRecord();

            if (common.TableId)
            {
                select common where common.(dimAttr.KeyAttribute) == dimAttrValue.EntityInstance;
                name = common.(dimAttr.NameAttribute);
                value = common.(dimAttr.ValueAttribute);
            }
        }
        info(dimAttr.Name +"----" +value + "----"+name);
    }

Monday, December 11

SSRS AX 2012 Error: Element ':PurchPurchaseOrder.Parameters.IsPurchConfirmationRequestJournal' has already been defined. To correct this, rename one or more of the model elements so that they have a unique name.

When we customize PurchPurchaseOrderReport to add a field on PurchPurchaseOrder Dataset in AOT and refresh dataset in Visual Studio.



We will get following error message:
Element':PurchPurchaseOrder.Parameters.IsPurchConfirmationRequestJournal’ has already been defined. To correct this, rename one or more of the model elements so that they have a unique name.


This is very common error and we can fix it by doing following steps: 
  1. Prior to refreshing Dataset, we have to rename the parameter IsPurchConfirmationRequestJournal to IsPurchConfirmationRequestJournalDelete
  2. Change the following properties:
    1. nullable – True
    2. allow blank – True
  3. Now refresh the dataset you should not see any errors and a new parameter IsPurchConfirmationRequestJournal will be created. Now set the below properties of new parameter:
    1. allow blank – True
    2. Nullable – True
  4. Once the properties are set, now delete the parameter ‘IsPurchConfirmationRequestJournalDelete’.
  5. Rebuild the solution and deploy the report.

Friday, November 3

AX 2012 - Different between AOT Table type (Regular , inMemory and Tempdb)

Different between AOT Table type (Regular , inMemory and Tempdb)

1: Regular: The default value. These are permanent tables.

2: InMemory: A temporary table that exists as an indexed sequential access method (ISAM) file.
The ISAM file can exist on either the client tier of the Application Object Server (AOS) tier.
The underlying Microsoft SQL Server has no connection to the ISAM file.
The system does allow you join an InMemory table in the X++ SQL syntax. However, joins and other set operations with InMemory tables are usually inefficient.
An InMemory table is the same thing as what was previously called a temporary table in Microsoft Dynamics AX 2009.


3: Tempdb: A temporary table that resides in the TempDB database of the underlying SQL Server.  The nonstandard format of a TempDB table causes the table to be dropped when it is no longer in use by the current method. Joins and other set operations on TempDB tables can be efficient.

AX 2012 - Returning Positive Next continuous Number Sequence in X++ code

Following below code show how we can get continuous number from the number sequences in Microsoft dynamics ax 2012.



SL_PositionReqNum   positionReqNum;
SysLastValue nextNumSeq;

ttsBegin;
positionReqNum = NumberSeq::newGetNumFromId(NumberSeqReference::findReference(extendedTypeNum(SL_PositionReqNum)).NumberSequenceId).num();
ttsCommit;

return positionReqNum;

AX 2012 - Convert Transdate (mm/dd/yyyy) format to cheque date format in ax 2012

Format the date to fit it in the boxes printed on the check paper like:



         // Date Formating Begins
        //format the date to fit it in the boxes printed on the check paper
        chequeTmp.SL_DateStr   = strFmt('%1', date2str(TransDate, 123, DateDay::Digits2, DateSeparator::None, DateMonth::Digits2, DateSeparator::None, DateYear::Digits4));

        j = strLen(chequeTmp.SL_DateStr);

        for(i = 1; i <= j; i++)
        {
            tempString = tempString + subStr(chequeTmp.SL_DateStr, i, 1);

            if(i != strLen(chequeTmp.SL_DateStr))
            {
                tempString = tempString + "    ";
            }
        }

        chequeTmp.SL_DateStr = tempString;

Tuesday, October 24

AX 2012 - Multi Table lookup - Display Fields from Multiple table in a lookup

Multi Table lookup - Where you can set lookup field from multiple table by joining multiple table and create a multi table lookup using SysMultiTableLookup. 

here is the Demo of the below code:




    Query                   query;
    QueryBuildDataSource    InventTrans;
    QueryBuildDataSource    GroupItem;
    QueryBuildDataSource    EcoRes;

    SysMultiTableLookup sysTableLookup;
    query = new Query();

    InventTrans = query.addDataSource(tableNum(InventTable));
    InventTrans.addRange(fieldNum(InventTable, SL_IncludeInSchemes)).value(queryValue(NoYes::Yes));

    //join the translation table so we can get a description of the UOM
    EcoRes = InventTrans.addDataSource(tableNum(EcoResProductTranslation));
    EcoRes.joinMode(JoinMode::InnerJoin);
    EcoRes.relations(false);
    EcoRes.addLink(fieldNum(InventTable,Product),fieldNum(EcoResProductTranslation,Product));

    //join the translation table so we can get a description of the UOM
    GroupItem = InventTrans.addDataSource(tableNum(InventItemGroupItem));
    GroupItem.joinMode(JoinMode::InnerJoin);
    GroupItem.relations(false);
    GroupItem.addLink(fieldNum(InventTable,ItemId),fieldNum(InventItemGroupItem,ItemId));
    GroupItem.addLink(fieldNum(InventTable,DataAreaId),fieldNum(InventItemGroupItem,ItemDataAreaId));

    //filter by the unit class being passed
    GroupItem.addRange(fieldNum(InventItemGroupItem, ItemGroupId)).value(queryValue(smmParametersTable::find().SL_SchemeReleaseItemGroup));

    //define multiple table lookup query
    sysTableLookup  = SysMultiTableLookup::newParameters(_formControl, query);
    //add which fields will be displayed to the user (symbol + desc.)
    sysTableLookup.addLookupfield(fieldNum(InventTable, ItemId), true);
    sysTableLookup.addLookupfield(fieldNum(EcoResProductTranslation, Name), 2);
    //do not use for multi table
    //sysTableLookup.parmQuery(query);
    sysTableLookup.performFormLookup();

Monday, October 23

AX 2012 - Get User Roles Associated with current user in X++ code

Following line of code fetch all roles associated with current login user in microsoft dynamics ax 2012.



static void Getuserroles(Args _args)
{
    SecurityRole role;
    SecurityUserRole userRole;
    UserInfo userInfo;
    ;
    while select role
        exists join userRole
            where role.RecId == userRole.SecurityRole &&
                       userRole.User == curUserId()
    {
        info(strFmt(“%1 – %2”, role.Name,curUserId()));
    }
}

Monday, October 9

AX 2012 - preRunModifyContract Method in controller class example

Here is an example for a preRunModifyContract method in which it simply fetch the PurchTable record and set the RecId in the contract class.

Function:

/// <summary>
/// Fetch the <c>PurchTable</c> record.
/// </summary>
/// <returns>
/// set <c>Contract</c> class for selected record recid.
/// </returns>
protected void preRunModifyContract()
{
    PurchTable                    PurchTable;
    LandCostContract           contract;

    contract = this.parmReportContract().parmRdpContract() as LandCostContract;
    PurchTable = this.parmArgs().record();

    contract.parmRecId(PurchTable.RecId);
}

AX 2012 - Calculating the hash Value of a string in X++ code

There is infinite number of ways how to compute a hash and, of course, different implementations and different hash algorithms have different properties. Below code is the most simplest code for generating a hash value of a string in SHA-256. you can update this code and provide your own hashing algorithm by editing the below line with the list of available hashing algorithm in MSDN.

System.Security.Cryptography.SHA512::Create();



Hashing Function:

public str CalculateHash(str tb)
{

    str s;
    ClrObject obj;
    ClrObject SHA256;
    System.Text.StringBuilder sBuilder;
    ClrObject clrStr;
    ClrObject clrStrObject;
    System.Exception clrException;
    System.Array resultByteArray;
    int i;
    int arrayLength ;
    InteropPermission perm;

    perm = new InteropPermission(InteropKind::ClrInterop);
    perm.assert();
    try
    {
        obj = System.Text.Encoding::get_ASCII().GetBytes(tb);
        SHA256 = System.Security.Cryptography.SHA512::Create();
        resultByteArray = SHA256.ComputeHash(obj);
        //BP deviation documented
        sBuilder = new System.Text.StringBuilder();
        arrayLength = resultByteArray.get_Length() ;
        // Loop through each byte of the hashed data
        // and format each one as a hexadecimal string.
        for (i = 0; i <arrayLength; i++)
        {
            clrStrObject = resultByteArray.GetValue(i);
            clrStr = clrStrObject.ToString('x2');
            sBuilder.Append(clrStr);
        }

        // Return the hexadecimal string.
        s = sBuilder.ToString();
    }
    catch (Exception::CLRError)
    {
        //BP deviation documented
        clrException = CLRInterop::getLastException();
        s = clrException.get_Message();
        error(s);
        throw error("@SYS106158");
    }

    CodeAccessPermission::revertAssert();
    return s;

}

Friday, October 6

AX 2012 - Difference between Form Methods , Form Data source Methods , Table Level Methods

1. Form methods can be overridden so as to change the behavior of the form in response to user interface events, and customize the appearance of a form

2. Form datasource methods can be overriden so as to change the behavior for validation, caching etc eg initvalue() can be used to fill in default values when creating a new record

3. Table methods is where most of processing codes should be placed instead of on form datasource methods. This can be overridden eg validateField() to validate a value in a field




See the below links for details:

Table Methods [AX 2012]

Methods on a Form [AX 2012]

Methods on a Form Data Source [AX 2012]


For this blog specially Thanks to robsmusau,

Thursday, October 5

SSRS Report - Can't see changes after deploying SSRS report AX 2012

Follow the following steps:
  1. If you are on R3, you have the Tools -> Caches -> Refresh report server;
  2. Also, do a Tools -> Caches -> Refresh elements and Tools -> Caches -> Refresh dictionary;
  3. If you have an AOT query, you can do a Restore on the query;
  4. Open the report in Visual Studio, and perform a Refresh on your dataset in the Datasets node;
  5. Also in Visual Studio perform a rebuild and a deploy of the report;
  6. Before step 5. you can check that the parameters you have for your report are the proper ones (if you've changed the data contract or the query);
  7. Depending on the decision to load the last values (controller.parmLoadFromSysLastValue) you want to do a Reset usage data;
  8. And last but not least, you want to do a Restore and then also a Deploy element on the report in the AOT.
If your still facing the issue then finally restart your SQL Server Reporting Services in service and run the report.

OR

sometimes you need to delete the report in the report document folder, then deploy again to get the latest version published. After that restart the SSRS service instance.

I hope that one of these helps.

Using AXBuild Command for Parallel Compilation of AOS in Microsoft Dynamics AX 2012

We can compile AOS direct from the development environment by Right click on AOS then compile, but it usually takes up to 4 to 6 hours depending upon your systems support. The direct method of compiling AOS takes much longer time, which may paralyze your work for hours.

So here comes a trick to compile AOS much faster than ever by AXBuild command which hardly takes up to 15 to 17 mins to compile the AOS. Before running the command, the following are the key steps to follow:

Step 1 - Go to Windows Search, type Services. Click on Service. Go to Microsoft Dynamics AX Object Service and stop the Dynamic AX Object service for a while before running the command.


Step 2 - Go to windows search, type cmd and open it as an administrator



Step 3 - Change your location to the Microsoft Dynamics AX bin folder. Just copy and paste below comment in cmd.

"C:\Program Files\Microsoft Dynamics AX\60\Server\TAVSP\bin"



Step 4 - Enter the below command to run a full compile on AOT in cmd

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


Note: After this multiple cmd are open which will run in parallel to compile different parts of AOT, to increase your parallelism you can add /w=03 in above command to increase number of threads.




Step 5 - For error logo cmd will show a location where all the error are write to file.


Step 6 - Go to the file location show in the command prompt and open the respective file for your purpose.







AX 2012 - Multi Table Lookup - Join many multi with root table to display a lookup on root table

Lookup table on form datasource field. Here is the code for multi table look.



public void lookup(FormControl _formControl, str _filterStr)
{
    Query                                query           = new Query();
    QueryRun                         QueryRun;
    QueryBuildDataSource    reasoncode;
    QueryBuildDataSource    inventTransWMS;
    SysTableLookup               sysTableLookup;
    ;

    super(_formControl, _filterStr);


    if(TmpInventTransWMS.InventQty < 0)
    {
        reasoncode  = query.addDataSource(tableNum(SL_TransferOrderReasonCode));

//<tag>Repeat<tag>
        inventTransWMS = reasoncode.addDataSource(tableNum(SL_InventTransWMS));
        inventTransWMS.fetchMode(JoinMode::ExistsJoin);

        inventTransWMS.relations(false);
        inventTransWMS.addLink(fieldNum(SL_TransferOrderReasonCode, Code),fieldNum(SL_InventTransWMS, SL_TransferOrderReasonCode));

        inventTransWMS.addRange(fieldNum(SL_InventTransWMS, InventDim)).value(queryValue(TmpInventTransWMS.InventDimId));
        inventTransWMS.addRange(fieldNum(SL_InventTransWMS, InventTransOrigin)).value(queryValue(InventTrans::findRecId(TmpInventTransWMS.InventTrans).InventTransOrigin));
        inventTransWMS.addRange(fieldNum(SL_InventTransWMS, InventTransOrigin)).value(queryValue(InventTrans::findRecId(TmpInventTransWMS.InventTrans).InventTransOrigin));

//you can add more data set by repeat from <tag>repeat</tag> tag.

        sysTableLookup = SysTableLookup::newParameters(tableNum(SL_TransferOrderReasonCode), _formControl);
        sysTableLookup.addLookupfield(fieldNum(SL_TransferOrderReasonCode, code));
        sysTableLookup.addLookupfield(fieldNum(SL_TransferOrderReasonCode, codeDescription));

        sysTableLookup.parmQuery(query);
        sysTableLookup.performFormLookup();
    }
}

Wednesday, October 4

AX 2012 - How to change the capture of form at runtime in X++

There are certain requirement in which we have to change the name of form based on certain field value, the below line can be inserted in any method where you want like active, init etc...



//field condition
if (condition)
{
       element.design().caption('New Label');
}

hope this will help you..

Friday, September 29

AX 2012: Forms - Row wise disable field based on other field value in grid

There are several ways to disable a field, but in many cases the whole column is disable. In these blog I am discussing about how to disable a field base on other field value.



Step 1:
First of all, you have to change the properties of your field in the form design, change the declaration property to YES.

Step 2: Go to Datasource in your form, select the field Datasource, in method override the active method and write you logic there.

For example:
In active method:

formfieldname.enable(datasourcename.fieldname > 3);

Whenever a record is active in a grid the above line base on condition update the form field.

Friday, September 8

Dynamics AX X++ Code - Amount To Word Conversion in X++ Code

There are many ways to convert REAL into string words but below code snippet is simple and easy to modify according to your business logic. This code will first round off you amount then convert it into Word. Hope you will find it useful.


For any recommendation and suggestion relate code kindly feel free and comment below if your answer is more accurate and better than mine.

public str AmountToWords(real _amount)
{

    int             amount;
    str             amount2Words;

    amount       = real2int(round(_amount , 1));
    amount2Words = Global::numeralsToTxt(amount);
    amount2Words = subStr(amount2Words,5,strLen(amount2Words)-4);
    amount2Words = subStr(amount2Words,strLen(amount2Words)-10,-strLen(amount2Words));
    amount2Words = '(Amount:' +' '+  str2Capital(amount2Words) + ' only)';
    
    return amount2Words;
}

Thursday, September 7

SRSS - How To Append 'st', 'nd', 'rd' or 'th' To Day Numbers in Dates

Microsoft Dynamics AX ERP systems in it is a large and completed ERP Solution of all Time, but different user have different sets of requirement to achieve his/her business goal. A common example among all is to append Day number with  'st', 'nd', 'rd' or 'th'. Which is not possible in SSRS Report, because there are a lots of format available for date but you will not found any solution regarding this problem.

The available format in SSRS Reports are as following:
Formatting Date and Time in SQL Server Reporting Services (SSRS) is a very common need. And in some cases customers look for a very specific format, so it is important to understand the basic components of date and time formats.
SSRS offers many in-built Date and Time formats. Below are some of the in-built Date formats available in SSRS:
For appending all the above suffix you need to follow following steps:
1. Open any Report in Visual Studio and insert a textbox contain Data Field of Date Type,

2. Right Click on Textbox, Go To Text Box Properties

3. Click on Number tab, click on custom format option then click on fx button in black.

4. A form will open, copy the below text and paste there to need to change following text with your database date field.

Fields!FieldName.Value, "Dataset"

1. Replace FieldName with your Date Field
2. Replace Dataset       with your Dateset Name


="d" + switch(int(Day((Fields!FieldName.Value, "Dataset"))) mod 10=1,"'st'",int(Day((Fields!FieldName.Value, "Dataset"))) mod 10 = 2,"'nd'",int(Day((Fields!FieldName.Value, "Dataset"))) mod 10 = 3,"'rd'",true,"'th'") + " MMMM, yyyy"


5. Press ok, Again ok. Deploy your report and check it on AX. Enjoy!!

Who Wins the ERP Systems Race - Dynamics AX, SAP or Oracle? - Microsoft Dynamics AX For a Reason

Why not any other ERP Solution beat Microsoft Dynamic AX, here are the Top Five Reason Microsoft Dynamics AX better than any other ERP Systems.


1. The Microsoft Dynamics AX is more than a General ERP system in terms of services and Technology, Dynamics 365 is the only first solution which provide cloud based ERP solution in the market todays.

2. Success behind any bussiness idea is ease of use, there are alot of example out there like Google, Microsoft also make there solution more ease to use for their client as well as for developer. Developer can code their out of box solution in Dynamics AX easily.


3. Another Key win over any other ERP Solution it's Dynamics AX flexibility. You can shape AX with your business logic and also you can submit your solution(entire Module) to Microsoft.

4. Microsoft has put a lot of emphasis on Life cycle Services (LCS), which features tools that enhance the efficiency and shorten the time with their system guided procedures and controls. It’s highly salable, making it easier to manage the entire life cycle of the software, from conference room pilot, through go-live, and on to post-implementation support.


5. It's US who makes Dynamics AX much greater than ever, how we can explore it open more dynamic ways which increase AX functionalities in term of anything like performances, consistences, Fast Development and Deployment, etc. 


Popular Posts