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();
          }
}