Thursday, 25 June 2015

I am writing this post to demonstrate to find exchange rate from code for SSRS report in Axapta 2012 R2 , R3.

I am writing this post to demonstrate find exchange rate for SSRS report  in Axapta 2012 R2 , R3.

"CurrencyExchangeHelper" class manages calculations between currencies. with the help of method "calculateCurrencyToCurrency" calculates the amount between the original currency and the resulting currency.

    Let's have a look..

    // find exchange rate
    CurrencyExchangeHelper                  curExchangeRate; ;
    AmountMst                                        calculateCurrency;
    curExchangeRate             = CurrencyExchangeHelper::newExchangeDate(Ledger::current(), systemDateGet());
    calculateCurrency       = currencyExchangeHelper.calculateCurrencyToCurrency("USD" , "SAR" ,1 , true);
    info(strfmt("%1", calculateCurrency));

Now you can get exchange rate USD to SAR , "calculatecurrency" variable provide you the current SAR exchange rate.



Thank you so much!

    

Wednesday, 17 June 2015

Call Multiple report on single click in X++, Code for apply Range on From


I am writing this post to demonstrate how to call multiple X++ report on single click in Microsoft Dynamics AX 2009/2012. 


Call Multiple report on single click in X++


void clicked()
{
    Args args = new args();
    ReportRun       reportRun;
    ;

    args.record(PurchTable);
    args.name(reportstr(Report1));
    reportRun = classFactory.reportRunClass(args);
    reportRun.init();
    reportrun.run();
    args.name(reportstr(Report2));
    reportRun = classFactory.reportRunClass(args);
    reportRun.init();
    reportrun.run();
    args.name(reportstr(Report13));
    reportRun = classFactory.reportRunClass(args);
    reportRun.init();
    reportrun.run();
    super();
}


I am writing this post to demonstrate provide rangle on Form in Microsoft Dynamics AX 2009/2012 and best practices to apply range on Form Datasource executeQuery.


public void executeQuery()
{
    QueryBuildDataSource    qbdRGDetail;
    QueryBuildRange         qbrECCNumber;
    QueryBuildRange         qbrNumberSequence;
    ;

    qbdRGDetail = TableName_ds.query().dataSourceTable(tablenum(TableName));
    qbdRGDetail.clearRanges() ;

    qbrECCNumber = SysQuery::findOrCreateRange(qbdRGDetail, fieldnum(TableName, ECCNumber));
    qbrECCNumber.value(TableName2.ECCNumber);
    qbrNumberSequence = SysQuery::findOrCreateRange(qbdRGDetail, fieldnum(TableName, NumberSequence));
    qbrNumberSequence.value(TableName2.NumberSequence);

    super() ;


}


Surrogate Key in Axapta 2012 and Table Inheritance among table.

Surrogate Key in Ax 2012 with example


Surrogate key is the system generated and  recid based field it is works on  primary key and it is managed by the kernel. InventTable using surrogate key and all other tables that have relations to InventTable using its surrogate key as a foreign key. In standard application scenarios, RecIds should not be displayed to the user, because a RecId by itself does not provide useful or easily understandable information and Surrogate key not for user interface. 

Example 
UnitOfMeasure table is the example of surrogate key. UnitofMeasure table exist symbol field that is the part of the SymbolIdx index which is represented as replacement key.



Inheritance Among Tables in Ax 2012 with example

This is the new feature in Axapta 2012 table inheritance we can extend drive table by setting the properties on table. In earlier version of Axapta their is no features to extend table. One table is the proposed base table and the other is the proposed derived table. You should consider the use of inheritance between two tables.And we can use table inheritance among the table we need to set the all the bellow properties at the time of creation of tables.

Abstract - Yes
InstanceRelationType - InstancerelationType
SupportInheritance - Yes.

Example - "EcoResProduct" table is the example of Table inheritance in ax 2012. 


when we have to add derived tables as a datasource   on a form thn all its children will added automatically under the derived datasources node. Filed from the derieved datasources can be bound  and linked to the form controls and we can add more datasource to the derived datasource.

Have a look --

EcoResProduct Table-

EcoResProductDetails Form-  



Thank you so much!!! :-)

Tuesday, 16 June 2015

Create dialog, Sending mail ,Send SMS in Axapta through code.

Job for creating Dialog Box.

static void Axapta_DialogBox(Args _args)
{
Dialog dl;
DialogGroup dlg;
DialogField dlF;
DialogBox dBx;
dl= new dialog(“Dialog Box”);
dlg= dl.addGroup(“Customer”);
dlF= dl.addField(extendedTypeStr(CustAccount));
dlg= dl.addGroup(“Customer Group”);
dlF= dl.addField(extendedTypeStr(CustGroupId));
if (dl.run())
dlf.value();
}

Code for sending mail in Ax

static void SendMail(Args _args)
{
PrintjobSettings printjobSettings;
PurchTable Ptbl;
vendtable vtbl;
QueryBuildDataSource qbd;
ReportRun report;
Args args = new Args();
RecordSortedList List = new RecordSortedList(62);
sysMailer mailer;
str _fileName;
str fromAddr;
str toAddr;
str subject;
str body;
str cc;
#AviFiles
SysOperationProgress progress = new SysOperationProgress();
int i;
if (Box::yesNo(‘Do you want to Send a mail ?’, DialogButton::No) == DialogButton::Yes)
{
progress.setCaption(“My Task”);
progress.setAnimation(#AviUpdate);
progress.setTotal(50000);
mailer = new sysMailer();
fromAddr = ‘sender mail id’ ;
toAddr = ‘rec Mail Id’ ;
subject = ‘Axapta Mail sent';
Body = ‘Purchase Order Report';
cc = ‘CC mail id’ ;
mailer.quickSend(fromAddr,toAddr ,subject,Body,cc,_fileName);
info(‘E-Mail is Sent Successfully aginst %1 this document number’);
//files deleted in ax folder
if (!isRunningOnServer())
{
if(WinAPI::fileExists(_fileName))
{
WinAPI::deleteFile(_fileName);
}
}
}
}

Send SMS in Axapta with intergration of webclient

Create a method in class and integrate Ax with webclient

str sendSMS(str txtTo, str txtMessage)

{
str txtUserName, txtPassword, txtSender, txtURL, txtGateway, txtCDMASender;
str txtResponse, txtSendString;
System.Net.WebClient cust;
System.IO.Stream data;
System.IO.StreamReader reader;
InteropPermission perm;

;
perm = new InteropPermission( InteropKind::ClrInterop );
txtUserName = ‘ABCD';
txtPassword = ‘abcd@123′;
txtSender = ‘XYZ';
txtGateway = ‘trans';
txtCDMAsender = ‘XXXXXXXXXX';
perm.assert();
cust = new System.Net.WebClient();

txtURL = ‘http://india.timessms.com/http-api/receiverall.asp?’ +
‘username=’ + txtUsername + ‘&password=’ + txtPassword +
‘&sender=’ + txtSender + ‘&cdmasender=’ + txtCDMASender + ‘&to=’ +
txtTo + ‘&message=’ + txtMessage + ‘&Gateway=’ +txtGateway;
data = cust.OpenRead(txtURL);

reader = new System.IO.StreamReader(data);

txtResponse = reader.ReadToEnd();
data.Close();
reader.Close();
return txtResponse;

}

Import General journal from excel in D365 F&O

 Hi Guys, Import General journal from excel in D365 F&O Code:  using System.IO; using OfficeOpenXml; using OfficeOpenXml.ExcelPackage; u...