Wednesday, 17 June 2015

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;

}

Tuesday, 17 March 2015

Learn Abstract Class and Abstract Method with examples

Learn  Abstract Class and Abstract Method with examples 



Abstract Class:
When we declare a class as abstract, this class cannot initiate in X++ code. To use this class or its method we have to first extend this class than only we are able to use this class or its method. To understand the abstract class consider following example
We have three classes
     1.      absClass  (it’s an abstract class)
     2.      normalClass (an another class which will use the absClass methods)
     3.      extendAbsClass (this class will extends the absClass)

    1.      abstract class absClass
     {
     }

    void printName()
   {
    ;    info("AbsClass... Deepak"); 
   }


    2.      class extendAbsClass extends absClass
{
}

    3.      class normalClass
{
}

  void accessAbsClass()
{
    absClass        absClass;
    extendAbsClass  extendAbsClass;
    ;
 //   absClass = new absClass();    // this declaration will throw error “Object could not be created because class absClass is abstract” so first we extend absClass into extendsAbsClass and further use extendsAbsClass to access absClass methods.
    extendAbsClass  = new extendAbsClass();
    extendAbsClass.printName();
}


Abstract Method:

When we declare a method as abstract , this method should be overload in child class or we can say , this method  should be declare/initiate in child class, than only we can use this class or its method.
Note:
a.      Abstract methods may only be declared in abstract classes.
b.      No code or declarations are allowed in abstract methods.

We have three classes
i.                    absMethodClass
ii.                  extendAbsClass
iii.                NormalClass

1.      abstract class absMethodClass
{
}

abstract void absPrintName()
{
                        // we cannot declare any code in abstract method
}

2.      class extendAbsClass extends absMethodClass
{
}

void absPrintName()
{
    ; // we have to initiate abstract method here as this class extends the abstract class.
    info("abstract method declaration in derived class");
}
3.      class childClass_1
{
}

void accessAbsClass()
{
    extendAbsClass  extendAbsClass;
    ;
    extendAbsClass  = new extendAbsClass();
    extendAbsClass.absPrintName();

}

Friday, 9 January 2015

Open Axapta X++ Report throw Clicked method.

Open Axapta X++ Report throw Clicked method.

void clicked()
{
    Args args = new args();
    ReportRun       reportRun;
    ;
    args.parm(salesTable.SalesId);

    args.name(reportstr(GiveReportName));
    reportRun = classFactory.reportRunClass(args);
    reportRun.init();
    reportrun.run();
    super();
}


Thank You!!

Introduction To dynamics Axapta

Microsoft Dynamics AX is an enterprise resource planning (ERP) solution for midsize and larger organizations that helps people to work effectively, manage change, and compete globally. Microsoft Dynamics AX works like and with familiar Microsoft software and is a solution that automates and streamlines financial, business intelligence, and supply chain processes in a way that can help you with your business.
The topics in this section provide information about the Microsoft Dynamics AX work space, common tasks that any user might complete, Enterprise Portal for Microsoft Dynamics AX information, and information about accessibility products and services from Microsoft.


Thanks You!!

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...