Tuesday, February 28, 2017

Simple Dialog In Ax 2012

Creating a Simple Dialog:

The application class Dialog is used to build dialogs. Other application classes, such as
DialogField, DialogGroup, DialogTabPage, and others, are used to create dialog
controls. A common way of using dialogs is within the RunBase framework classes, where
user input is required

Steps:

  1. Expand AOT and create a new Class and name it CustCreate as me..
  2. And Copy the following Code
method 1;

class CustCreate extends RunBase
{
DialogField fieldAccount;
DialogField fieldName;
DialogField fieldGroup;
DialogField fieldCurrency;
DialogField fieldPaymTermId;
DialogField fieldPaymMode;
CustAccount custAccount;
CustName custName;
CustGroupId custGroupId;
CurrencyCode currencyCode;
CustPaymTermId paymTermId;
CustPaymMode paymMode;
}

method 2;

public container pack()
{
return conNull();
}

method 3:

public boolean unpack(container _packedClass)
{
return true;
}

method 4:

protected Object dialog()
{
Dialog dialog;
DialogGroup groupCustomer;
DialogGroup groupPayment;
dialog = super();
dialog.caption("Customer information");
fieldAccount = dialog.addField(extendedTypeStr(CustVendAC),"Customer account");
fieldName =dialog.addField(extendedTypeStr(CustName));dialog.addTabPage("Details");
groupCustomer = dialog.addGroup("Setup");
fieldGroup = dialog.addField(extendedTypeStr(CustGroupId));
fieldCurrency = dialog.addField(extendedTypeStr(CurrencyCode));
groupPayment = dialog.addGroup("Payment");
fieldPaymTermId = dialog.addField(extendedTypeStr(CustPaymTermId));
fieldPaymMode = dialog.addField(extendedTypeStr(CustPaymMode));
return dialog;
}

method 5:

public boolean getFromDialog()
{
custAccount = fieldAccount.value();
custName = fieldName.value();
custGroupId = fieldGroup.value();
currencyCode = fieldCurrency.value();
paymTermId = fieldPaymTermId.value();
paymMode = fieldPaymMode.value();
return super();
}

method 6:

public void run()
{
info("You have entered customer information:");
info(strFmt("Account: %1", custAccount));
info(strFmt("Name: %1", custName));
info(strFmt("Group: %1", custGroupId));
info(strFmt("Currency: %1", currencyCode));
info(strFmt("Terms of payment: %1", paymTermId));
info(strFmt("Method of payment: %1", paymMode));
}

method 7:

public static void main(Args _args)
{
CustCreate custCreate = new CustCreate();
if (custCreate.prompt())
{
custCreate.run();
}
}

3.In order to test the dialog, run the class. The following form should appear with the
General tab page open initially:
4.Enter the cust account and name 

5.And in Detail Tab enter following data
6. click ok

Monday, February 27, 2017

How to Create Foregin Key Relation In AX 2012

Table Relation:

Foreginkey Relation  For Example

  1. First create a new table like Foreginkey table and add a new fields as u want 
  2. And create new ETD as ID and drag into Foreginkey table
  3. Then create  new index for table in the name of ID
  4. In Index property set alternate key "YES" and allow duplicates "NO" 
  5. Then In Foreginkey table property set primary key as Index name "ID" in lookup
  6. And then  ETD "ID" property set  ---> reference table ---> as Foreginkey Table
  7. Then expand the ETD "ID" right click ----> table reference ---> new table reference and related field as "ID"

  8. At last if u  drag an ETD to any other table it will appear like this 
  9. This is foregin key relation.