Thursday 30 October 2014

Optimizing display methods in AX 2012

Check the following link for detail of display method.what developer must be care before using it.

http://www.axpulse.com/optimizing-display-methods-in-ax-2012/
http://daxdude.blogspot.com/2013/05/dynamics-ax-cacheaddmethod.html

Wednesday 24 September 2014

Debugging AIF services of Microsoft Dynamics AX 2012 in Visual Studio

If do you want to debug AIF service's in VS  checked following useful links

http://dynamicsaxsol.blogspot.com/2013/06/debugging-aif-services-of-microsoft.html


http://daxdilip.blogspot.in/2010/05/aif-links.html

Thursday 19 June 2014

Read data from live website in Ax2012

With the help of following code we can easily read data from live website

static void ReaddataFromLivewebSite(Args _args)
{
    #DEFINE.BLOGCONTENT('http://www.lme.com/en-gb/metals/non-ferrous/copper/')
    int         curPos=1;
    int         endPos;
    int         startPos=1;
    str         data;
    str         internetURL;
    int         price;
    TextBuffer  textBuffer;
    System.Net.WebRequest request;
    System.Net.WebResponse response;
    System.IO.StreamReader  streamReader;

    request=System.Net.WebRequest::Create(#BLOGCONTENT);
    response= request.GetResponse();
    streamReader=new System.IO.StreamReader(response.GetResponseStream());
    textBuffer =new TextBuffer();
    textBuffer.setText('');
    data = streamReader.ReadToEnd();
    streamReader.Close();
    textBuffer.setText(data);
    textBuffer.regularExpressions(false);
    textBuffer.find('Cash Seller & Settlement', curPos);
    startPos=textBuffer.matchPos();
    textBuffer.find('3-months Buyer');
    endPos=textBuffer.matchPos();
    data=textBuffer.subStr(startPos, endPos - startPos);
    data =   strReplace(data,'',"");
    data =   strReplace(data,'',"");   
    data =   strReplace(data,' ',"");
    data =   strReplace(data,'',""); 
    internetURL= strRem(strreplace(data,'Cash Seller & Settlement',''),'"');
    price = str2int(internetURL);
    internetURL = int2str(price);
    info(internetURL);
    response.Close();

}

Tuesday 10 June 2014

Calculate LabelIds against Label field Id in AX2012 using X++

I have calculated a total number of label id's against Label file id . In my case Label file Id is "NVS".

static void maxLabelIds(Args _args)
{
    SysLabel   SysLabel;
    int maxLabelId;
    ;
    SysLabel =  new SysLabel('EN-US');
    maxLabelId = SysLabel.maxLabelId('NVS');
    print maxLabelId;
    pause;
}

Saturday 17 May 2014

Using AIF Inbound and Out Bound service check Exception in Ax2012



I used AIF inbound service when any error occurred in AIF. Errors did not  shown in exception window of AIF. Errors must be looks like a following screen but in my case it's shown empty.













Solution:
In my scenario
few lines of code is missing inside this class i.e "AxdLedgerGeneralJournal" in method of "prepareForSave" those lines are following


Find a char in string and replace new char using x++ in Ax2012


In following example we are find a char i.e "," in string and replace this char with new one char i.e ".".

static void FindCharAndRepalce(Args _args)
{

    str a;
    int pos;
    ;
 
    a     = "100,00";
    pos =  strFind(a, ',',1, strLen(a));
    a     =  strDel(a,pos,1);
    a     =  strIns(a,'.',pos);
    info(strFmt("%1",a));
}

Saturday 3 May 2014

SSRS Report does not display any records in Report Viewer Ax2012

Issue:
A customize report which also contain sub reports that report is unable to view in report viewer  but when we saved it in PDFs or printer preview it's printable and records are printed on it.

Solution:
 in my case report contain image in header and it's have some issue in logo i removed it and report view successfully. I also check the following link.

http://blogs.msdn.com/b/axsupport/archive/2013/03/13/ax2012r2-report-does-not-display-any-records-in-report-viewer.aspx


Security Role assign in Ax2012

Last few days i am facing following issue
I have assigned multiple roles to a user Like " Human Resource Assistant" and "Human Resource Manager". when i was assigned these roles to a user then on worker or Employee form i am unable see the records of  personal contract i.e Phone and address.
But when i assign system admin role then it's shown . I have  had also drag all tables related to this personal contract information in side the above roles but no effect .

Solution:
Go to the following path and open window assigned your required roles 
Organization administration -->setup---> Global address book parameter 

Friday 7 March 2014

How rename the record in Ax2012?

we are using right click on record and use record information for renaming record.
Following job use to rename the record .

static void CustomerAccountRename(Args _args)
{
     CustTable custTable;
    select firstOnly custTable
          where custTable.AccountNum == '1101';
          if (custTable.RecId)
         {
                 custTable.AccountNum = '1101_';
                 custTable.renamePrimaryKey();
          }
}

Wednesday 19 February 2014

Top 10 issues discovered from Dynamics AX Code Review

Check the following link related to Dynamics Ax2012   X++ coding point of view

http://blogs.msdn.com/b/axinthefield/archive/2014/02/18/top-10-issues-discovered-in-the-dynamics-ax-code-review.aspx

Friday 7 February 2014

X++ Debugging Tips and Tricks

I found a useful link for debugging x++.Here i am going to share this link

http://blogs.msdn.com/b/mfp/archive/2013/09/23/x-debugging-tips-and-tricks-part-1.aspx

How Create Customize Look up for Financial Dimension in Ax2012

Following lookup help for dimension filtration according to enum value over here
DimType  is customized filed which contain  Department, CostCenter, Project, Account  and BusinessUnit.
Select any one option then use following code of lookup for filter                                                                

public void lookup()
{

    Query query = new Query();
    QueryBuildDataSource                queryBuildDataSource;
    QueryBuildRange                         qbrForAccount;
    SysTableLookup                           sysTableLookup;
    DimType                                        dimType;
    DimensionAttribute                        dimensionAttribute;
    DimensionAttributeDirCategory       dimAttributeDirCategory;
    ;

    dimType = str2enum(dimType,FilterGroup_Type.valueStr());

    switch(dimType)
    {
        case  DimType::Department:

            sysTableLookup = SysTableLookup::newParameters(tableNum(OMOperatingUnit),this,true);
            sysTableLookup.parmUseLookupValue(false);
            sysTableLookup.addLookupfield(fieldNum(OMOperatingUnit, OMOperatingUnitNumber));
            sysTableLookup.addLookupfield(fieldNum(OMOperatingUnit, Name));
            queryBuildDataSource = query.addDataSource(tableNum(OMOperatingUnit));
            queryBuildDataSource.addSortField(fieldnum(OMOperatingUnit,OMOperatingUnitNumber));
            queryBuildDataSource.addRange(fieldNum(OMOperatingUnit,      OMOperatingUnitType)).value(int2str(any2int(OMOperatingUnitType::OMDepartment)));
            sysTableLookup.parmQuery(query);
            sysTableLookup.performFormLookup();
            break;

        case  DimType::BusinessUnit:

            sysTableLookup = SysTableLookup::newParameters(tableNum(OMOperatingUnit),this,true);
            sysTableLookup.parmUseLookupValue(false);
            sysTableLookup.addLookupfield(fieldNum(OMOperatingUnit, OMOperatingUnitNumber));
            sysTableLookup.addLookupfield(fieldNum(OMOperatingUnit, Name));
            queryBuildDataSource = query.addDataSource(tableNum(OMOperatingUnit));
            queryBuildDataSource.addSortField(fieldnum(OMOperatingUnit,OMOperatingUnitNumber));
            queryBuildDataSource.addRange(fieldNum(OMOperatingUnit, OMOperatingUnitType)).value(int2str(any2int(OMOperatingUnitType::OMBusinessUnit)));
            sysTableLookup.parmQuery(query);
            sysTableLookup.performFormLookup();
            break;

        case  DimType::CostCenter:


            sysTableLookup = SysTableLookup::newParameters(tableNum(OMOperatingUnit),this,true);
            sysTableLookup.parmUseLookupValue(false);
            sysTableLookup.addLookupfield(fieldNum(OMOperatingUnit, OMOperatingUnitNumber));
            sysTableLookup.addLookupfield(fieldNum(OMOperatingUnit, Name));
            queryBuildDataSource = query.addDataSource(tableNum(OMOperatingUnit));
            queryBuildDataSource.addSortField(fieldnum(OMOperatingUnit,OMOperatingUnitNumber));
            queryBuildDataSource.addRange(fieldNum(OMOperatingUnit, OMOperatingUnitType)).value(int2str(any2int(OMOperatingUnitType::OMCostCenter)));
            sysTableLookup.parmQuery(query);
            sysTableLookup.performFormLookup();
            break;
        case  DimType::Project:

            dimensionAttribute = DimensionAttribute::findByName("Project");
            if (dimensionAttribute.Type == DimensionAttributeType::CustomList)
            {
            select firstonly DirCategory from dimAttributeDirCategory where dimAttributeDirCategory.DimensionAttribute == dimensionAttribute.RecId;
            sysTableLookup = SysTableLookup::newParameters(tableNum(DimensionFinancialTag), this,true);
            sysTableLookup.addLookupfield(fieldNum(DimensionFinancialTag, Value));
            sysTableLookup.addLookupfield(fieldNum(DimensionFinancialTag, Description));
            query = new Query();
            query.addDataSource(tableNum(DimensionFinancialTag)).addRange(fieldNum(DimensionFinancialTag, FinancialTagCategory)).value(queryValue(dimAttributeDirCategory.DirCategory));
            sysTableLookup.parmQuery(query);
            sysTableLookup.performFormLookup();
            }
            break;


        case DimType::Account:

            sysTableLookup = SysTableLookup::newParameters(tableNum(MainAccount),this,true);
            sysTableLookup.parmUseLookupValue(false);
            sysTableLookup.addLookupfield(fieldNum(MainAccount, MainAccountId));
            sysTableLookup.addLookupMethod(tableMethodStr(MainAccount, localizedName));
            sysTableLookup.addLookupfield(fieldNum(MainAccount, Type));
            queryBuildDataSource = query.addDataSource(tableNum(MainAccount));
            qbrForAccount = queryBuildDataSource.addRange(fieldNum(MainAccount,LedgerChartOfAccounts));
            qbrForAccount.value(queryValue(Ledger::current()));
            queryBuildDataSource.addSortField(fieldnum(MainAccount,MainAccountId));
            sysTableLookup.parmQuery(query);
            sysTableLookup.performFormLookup();
            break;

     
}

Friday 17 January 2014

Development Tips on Application Integration Framework

I have read one article before start development of  AIF. Check the following links

http://axblog4u.wordpress.com/2010/11/23/development-tips-on-application-integration-framework/

http://blogs.msdn.com/b/aif/archive/2012/05/07/how-to-serialize-int-real-properties-with-0-0-00-values-via-aif-outbound-integration.aspx

http://www.dynamics101.com/2013/11/creating-custom-inbound-aif-service-microsoft-dynamics-ax-2012/

Thursday 16 January 2014

Inbound port of AIF Ax2012 using File system Adapter

Few things must be noted: ( Inbound port of AIF Ax2012 using File system Adapter )
If your client/Other vendor  has given you XML . They want to import in to AX using AIF. Don’t try to import that xml  according to standard schema of that service.
You must change customize schema from Data Policies inbound port according to you xml tags.
After change of Data Policies you must change your XML tags according to sequence of Data Policies enabled fields.
Generate XML according to standard  XML schema  of  AX
You can check schema nodes related to your action from AX  then mention all nodes in your XML.
Do you want to find all active and deactivate service in Ax ?Fallow the following path





Error 1:
Solution:
Such type of error arise when you xml file come's from BizTalk server and your xml tag contain
instead of
so change it into
OR
When you have found above type error then you can go to the following path

Check the xml output fault message in above path and here you can find some fields tags are missing according to standard schema
The tag '/LedgerGeneralJournal/SenderId' is not allowed; it must be removed or marked null.


Error 2:  Invalid document schema. The following error was returned:  Could not find schema information for the element.
Solution: you can verify your XML tags according to your XML schema from Data Policies.

Error 3:  The tag '/LedgerGeneralJournal/DocPurpose' is not allowed; it must be removed or marked null.
Solution: you can verify your XML tags according to your XML schema from Data Policies. Or just pass null for that tag in your XML.
Error 4:  An error has occurred in the services framework. Method: AifMessageInspector::AfterReceiveRequest. Error: System.ServiceModel.FaultException`1[Microsoft.Dynamics.Ax.Services.AifFault]: Request Failed. See the Exception Log for details. (Fault Detail is equal to Microsoft.Dynamics.Ax.Services.AifFault.


Solution: Check the following screen and configure your service according to these number 1 and check your accurate issue in number 2 path
Error 5: 
Stack trace: The company  does not exist.

Solution:
I am using standard Schema of XMl when I am facing above issue. So I have modified my XML schema from data policies and enable that filed in my schema, add new tag of company filed in my XML.
Error 7:   This is an invalid xsi:type 'AxdEntity_CustInvoiceLine'
Solution: Check your service XML Schema and change tag according to Schema.
Error 8:   Account and offset account cannot be the same
Solution:
If XML contain same value in tags of account and offset account then you can face above issue.
Be make sure both  account number and offset account value is change(i.e Account number = 0101 and offset account = 0102).
Error 9: The request failed with the following error:  Invalid document schema. The following error was returned:  Could not find schema information for the element.
Solution:
When you are putt wrong tags according to schema. Check Data Policies on inbound port form and verify your XML tags according to schema.
Error 10: The request failed with the following error:  Object reference not set to an instance of an object
Solution: When you are putt wrong tags according to schema. Check Data Policies on inbound port form and verify your XML tags according to schema.
Or
If your any tag of xml has wrong data according to destination system table data filed data . then verify you are xml data and your destination system data  

also check this link
http://mybhat.blogspot.com/2013/03/aif-object-reference-not-set-to.html

Error 11: The following error was returned:  The required attribute 'class' is missing
Solution:
Verify your XML file according to your XML Schema.
Error 12: The request failed with the following error:  Duplicate message. Message has already been processed.
Solution:
If your xml file contain same message id which one you have already import in Ax.Only change the message id value at the end of id i.e
{5603D03A-4380-404D-9F27-738BE0FEA14F} already inserted message
Change it as following
{5603D03A-4380-404D-9F27-738BE0FEA18F}
Error 13: Error found when validating record
Solution:
Such type of error occurred. When you’re XML tags contain different value than Ax setup value
For example Ax setup value is following
1102
Your XML contain following value
1111

Error 14: The request failed with the following error:  Creation has been canceled.
Solution:  Such type of error occur when your xml mandatory tag is missing in your xml file