Tuesday 6 November 2012

Only 2 clicks to get help on how to use functions with example [In Editor]

This post will be very helpful for the developers who are new and are looking for an example on how to use a functions with an example . Usually any developer who is very new to Dynamics AX will go to AOT >> System Documentation >> functions and will select a function >> right clicks and use edit option to get help on the function and example if any.
Well, I know its very boring way to go always to that level and get help. I have modified Editorscripts class again to get quick help in the editor itself.
All you need to do is add the below method “ShowExample” to the EditorScripts class

public void ShowExample(Editor editor)
{
str line;
int i;
int startLine = editor.selectionStartLine();
int endLine = editor.selectionEndLine();
int startCol = editor.selectionStartCol(); //points at the first selected char
int endCol = editor.selectionEndCol()-1; //points at the last selected char
MarkMode markMode = editor.markMode();
#define.maxLineLength(300)
#AOT
Form formBrowse;
FormHTMLControl htmlControl;
FormRun formRun;
Args args;
str htmlContent;
TreeNode functionTreeNode;
Editor _editor = editor;
str h1Tag;
void transform(str _function)
{
;
functionTreeNode = TreeNode::findNode(#SystemFunctionsPath+’\\’+_function);
if (!functionTreeNode)
throw error (“Function not found in System documentation”);
formBrowse = new Form(‘Function Example’, true);
formBrowse.design().caption(_function + ” Example”);
formBrowse.design().width(700);
formBrowse.design().height(500);
formBrowse.design().addControl(FormControlType::HTML, ‘html’);
args = new Args(formBrowse.name());
args.name(formBrowse.name());
args.object(formBrowse);
formRun = classFactory.formRunClass(args);
formRun.init();
htmlControl = formRun.design().controlName(‘html’);
htmlControl.height(1,1);
htmlControl.width(1,1);
formRun.run();
htmlControl.setText(functionTreeNode.AOTgetSource());
formRun.detach();
}
void transformLine(int lineNo, int start, int end)
{
_editor.gotoCol(0);
_editor.gotoLine(lineNo);
line = _editor.currentLine();
transform(substr(line, start, end-start+1)) ;
return;
}
;
editor.unmark();
switch (markMode)
{
case MarkMode::LineMark:
editor.gotoCol(1);
for (i=startLine; i<=endLine; i++)
{
transformLine(i, 1, #maxLineLength);
}
break;
case MarkMode::ColMark:
for (i=startLine; i<=endLine; i++)
{
transformLine(i, startCol, endCol);
}
break;
case MarkMode::AreaMark:
if (startLine == endLine)
{
transformLine(startLine, startCol, endCol);
}
else
{
//convert first line
transformLine(startLine, startCol, #maxLineLength);
//convert full lines
for (i=startLine+1; i<endLine; i++)
{
transformLine(i, 1, #maxLineLength);
}
//convert last line
transformLine(endLine, 1, endCol);
}
break;
}
}

Wondering how to use it now.
Create a new job and write any function. In the below example I have shown this by using strfmt function. Double click the function and select scripts button>> Show example as shown below

There you go. you will get help on how to use this function with an example on your screen. Isn’t it helpful?? Below is the output form which gives you quick help on the functions. You can get the help for any function which is defined in system documentation.

Friday 2 November 2012

Use resource files in Axapta

Axapta provides a very handy feature to allow developers to ship their solution with Axapta built-in image files. In Application Object Tree, you can find resources node. Select resources node and right click; select Create from File, specify the file location for the new resource file. After that you can use this resource file in Axapta without specifying an absolute file path in your hard disk.
Then let’s see how to use this kind of files in Axapta.
First, pick up the resource node from AOT;
SysResource::getResourceNode();
Then generate a temporary file for this resource file;
SysResource::saveToTempFile()
Finally specify the temporary file path for controls.
Here comes an example to show how to use a resource file as a background image of  a given form.
    {        ResourceNode            resourceNode;
        FilePath  imagename;
        ;
        resourceNode = SysResource::getResourceNode(resourcestr(ResourceName)); 
        if (resourceNode)
        {
            resourceNode. AOTload();
            imagename =  SysResource::saveToTempFile(resourceNode);
        }
        else
        {
             throw Error("No file exists.")
        }
        element.design().imageName(imagename);
    }

Monday 15 October 2012

Creating a new line in a grid using command button



under click method of command button use the following code;

void clicked()
{
   <tablename>_ds.create(true);
   super();
}

Thursday 11 October 2012

Sunday 23 September 2012

Finding unused labels in Dynamics Ax 2009

static void FindUnUsedLabels()
{
    str 50          labelId;
    str             labelString;
    int             i;
    //set max label to the highest number of labelId in your application
    int             maxLabel = 2000;
    xRefNames       names;
    XRefReferences  ref;

    ;

    while (i <= maxLabel)  
    {
        //Sequential generation
        labelId = "@IFC" + int2str(i);
        
        //Find if the label id has an cross reference
        //record
        select recid from names
            where names.Name == labelid
        exists join ref
            where names.RecId == ref.xRefNameRecId;

        labelString = SysLabel::labelId2String(labelId);
        
        //If there is no record in cross reference then log it
        if (! names.RecId &&
        //avoid logging labels that are already deleted (This is because of sequential check like IFC1, IFC2, IFC3 etc...)
            labelString != labelId)
        {
            info(strfmt("%1 - %2\n", labelId, SysLabel::labelId2String(labelId)));
        }

        i++;
    }

}

Thursday 20 September 2012

use display method as titlefield

1. in the caption() method of table write the below code
public str caption()
{
str ret;
ret = super();
ret = this.news() ; // news is a display method
return ret;
}
In the form design mention the datasource of table name
you can use it if  you need even a single field ,not more than 2 field.. you can display any number of fields
just  use and return the display method in the caption method of table


or

Code to disply the emp_id on the title bar of the form

Path : MyEmplForm-->Data Sources-->MyEmplTable-->Methods-->active()


public int active()
{
    int  ret;
    ret  = super();
    element.design().caption(EmpLeaveDetails.Emp_Id);
    return  ret;
}
 

Monday 17 September 2012

Processing multiple records

In my practice, I was asked a number of times to create various application functions that
process user-selected records in a form grid. Regardless of what function is being created, the
first step was always to determine what records were selected by the user.
In this recipe, we explore several ways of achieving this goal. We will modify the Items form
in the Inventory management module by adding a new button to it, which lists currently
selected records in the overview grid.
How to do it…

1. In AOT, open the InventTable form and create a new method with the following code:
void processSelectedItems()
{
InventTable inventTableLocal;
;
for (inventTableLocal = InventTable_ds.getFirst(true) ?
InventTable_ds.getFirst(true) :
InventTable;
inventTableLocal;
inventTableLocal = InventTable_ds.getNext())
{
info(strfmt(
“You’ve selected item ‘%1′”,
inventTableLocal.ItemId));
}
}
2. Add a new Button to the form’s ButtonGroup group:
Property Value
Name ProcessSelectedItems
Text Process
MultiSelect Yes
3. Override its clicked() with the following code:
void clicked()
{;
super();
element.processSelectedItems();
}
4. To test the record selection, open Inventory management | Item Details, select
several records using SHIFT or CTRL and click the Process button. The selected
items should be displayed in the Infolog:
How it works…
The key element in this recipe is a for statement in processSelectedItems(). First, it
checks if more than one record is selected by calling getFirst(true) on the InventTable
form data source. If yes, the for loops all the selected records from the data source,
otherwise it uses the cursor, which corresponds to the currently selected single record. All
selected records are then stored in the local variable inventTableLocal. In this example,
we just output inventory item numbers into the Infolog using the global info() function.
The ProcessSelectedItems button is used to call the function above once the user clicks it.
Notice that its property MultiSelect is set to Yes to ensure it is still enabled when multiple
records are selected.
There’s more…
I have also experienced that sometimes Dynamics AX users struggle to select multiple records
using SHIFT or CTRL. Sometimes, it is not clear that the form itself supports multiple record
processing. In such cases a more convenient way of selecting multiple records could be to add
a new checkbox in front of each record. This would remove all confusion and improve user
experience. In order to implement that, we need to make few changes to the example above.
First, we add a new Map variable to the form’s class declaration:
Map marked;
And in the form’s init() right after the variable declaration section we create its instance:
marked = new Map(Types::Int64, Types::String);
Then, we create a new edit method on the InventTable data source with the following code:
edit boolean editMark(
boolean _set,
InventTable _inventTable,
boolean _mark)
{;
if (_set)
{
if (!_mark)
{
if (marked.exists(_inventTable.RecId))
{
marked.remove(_inventTable.RecId);
}
}
else
{
marked.insert(
_inventTable.RecId,
_inventTable.ItemId);
}
}
return marked.exists(_inventTable.RecId);
}
We also add a new CheckBox to the top of the form’s Grid in the Overview tab page with the
following properties:
Property Value
Name Mark
Label Select
DataSource InventTable
DataMethod editMark
Finally, we have to modify processSelectedItems() to loop though the map. Replace the
method with the following code:
void processSelectedItems()
{
MapEnumerator mapEnumerator;
;
mapEnumerator = marked.getEnumerator();
while (mapEnumerator.moveNext())
{
info(strfmt(
“You’ve selected item ‘%1′”,
marked.lookup(mapEnumerator.currentKey())));
}
}
Open the Items form again and notice that now it has a new checkbox Select in front of
each record. Pick several records using it and click Process. The selected items should be
displayed in the Infolog:
The principle of this technique is that we use a Map type object to store the list of selected
item numbers. The editMarked() method is bound to the checkbox control and is
responsible for adding a record to the map upon user selection and removing it from the map
if the user deselects the checkbox.
We also use the MapEnumerator class to retrieve item numbers from the map for
further processing.

Wednesday 12 September 2012

adding table for search.

Adding table for search.

Its a new feature in ax 2012,which it makes our table to be searchable.means using this feature we have chance to search data in table .

this is possible using as following ,


steps involved:

1: go to aot -->tables--> properties-->modifieddatetime property to yes save it
2:create a query which is having name with good meaning make the datasource as your table and go to properties of datasouce change the name to table name that you want to search and change the dynamic property of fields to yes.and go to properties of query and make searcheble option to yes.
3.at last restart the service that is Dynamics ax  object server .

Wednesday 5 September 2012

how to use menu item dynamically ?

how to use menu item directly ?

we will use menuitem directly using a class called menufuntion .

menufunction=new menufunction(menuitemoutputstr(reportname));//in case of report
                                                  menuitemdisplaystr //in case of form
                                                  menuitemactionstr //in case of class

Working with external database.

Working with external database :-


In this example i will explain how to access external sqlserver database tables in ax .

Steps:

Before going to work with database we have to first create a DNS through which we access external database .to create dns follow these steps,
 1)Administration Tools-->Database(odbc)
2)Dsn-->add (which opens a wizard)-->select sqlserver-->finish
3)(opens another window consists of) referdatasource name : give any name let us it is AX
     a)description:AX
    b)server:(its your server name) to which you want to connect
   c)next,next,finish-->testdatasource -->test connection
This finishes DNS creation

step2:

create a new job as follows:

static void odbcTest(Args _args)
{
  odbcconnection odbc;
LoginProperty login;
Statement st;
ResultSet rt;
;
login=new LoginProperty();
login.setDSN("AX");
login.setDatabase("AX593");
odbc=new odbcconnection(login);
st=odbc.createstatement();
rt=st.executequery("select * from custtable");
while(rt.next())
{
 info(rt.getstring(1));//here 1-represents coloumn number
info(rt.getstring(2))
}
}
}

Edit Method Example on table.

Edit Method on table methods:-

We have 2 methods which we used to access another table data in our form in which we don't have that table as data source.Those are display and edit methods.

Edit method example:

 Suppose take  2 tables  cartable and rental table

 cartable fields-->1)carid as edt and primary index
                           2)Milege as edt

Rental Table Fields-->1)Carid 
                                 2)Custid

steps:

make a relation between cartable and rental table (normal relation in rental table with carid)
create a find method in cartable as

public static cartable find(carid _carid )
{
 cartable car;
 ;
 select car where car.carid==_carid;
 return car;
}

now create an edit method in rental table to edit milege of carid in cartable ,the method looks like

edit milege editmilege(boolean set,milege value)
{
  cartable cartable;
  milege ret;
  ;
cartable=cartable::find(this.carid);

if(set)
{
cartable.selectForUpdate(true);
 ttsbegin;
 cartable.milege=value;
 cartable.update();
 ttscommit;
 return value;
}
else
{
 ret=cartable.milege;
}
return ret;

}

now to test this create a form with rental table as data source and create a grid in design .Drag this edit method into grid it creates a column mileage .

open form and change the milege value it reflects in cartable .this is possible in case of edit method .if we use display method we cannot have a chance to change value .


 

Friday 17 August 2012

SysEmailBatch ?

SysEmailBatch mailer;
 
mailer = SysEMailBatch::construct();
mailer.parmPriority(emailPriority::Normal);
mailer.parmSenderAddr("Sender@mail.com");
mailer.parmSendername("Your name");
mailer.parmEmailAddr("receiver@mail.com");
mailer.parmEmailName("Receiver name");
mailer.parmSubject(subject);
mailer.parmMessageBody(msgBody);
 
mailer.run();

Thursday 16 August 2012

Mandatory DialogField

When adding controls to a standard form, either bound to a data field or not, one useful property is the Mandatory property. If this is set, then the control is shown with a red squiggly line if no value has been entered, and an error will automatically be shown when the user tries to save the record or close the form. This article describes how to also make this functionality available from dialog forms. You need to define the mandatory property in a DialogField class, as shown below.
1. Add mandatory() method into DialogField class:
// Created by GRR on 01.11.2005
void mandatory(boolean r)
{
    str name;
    // If properties exists then we are on server
    if (properties)
    {
        name = #Propertymandatory;
        if (! properties.exists(name))
            properties.add(name,true);
        properties.value(name,r);
    }
    else
        this.fieldControl().mandatory(r);
}
2. Add into unpack() method following lines:
case #PropertyMandatory:
    this.mandatory(unpackedProperties.valueIndex(i));
    break;


Determining if an object is a subclass

It can sometimes be useful to determine if an object is a instance of a subclass of some specified parent class.
While over-use of this probably suggests a class framework which has not been well designed, it is valuable in specific instances.
There are two static methods on the SysDictClass which can be used for this purpose:
static boolean isSuperclass(classId  _id, classId  _potentialAncestorId)
This method checks if the classId passed in _id is a subclass of the _potentialAncestorId
static boolean isEqualOrSuperclass(classId  _id, classId  _potentialAncestorId)
This method checks if the classId passed in _id is a subclass of the _potentialAncestorId, and will also return true if _id equals _potentialAncestorId
The following code uses the SalesTableType heirarchy as an example.
SalesTableType          stt;
SalesTableType_Journal  stt_j;
;
 
// This is true as stt is an ''instance'' of SalesTableType
if (SysDictClass::isEqualOrSuperclass(classidget(stt), classnum(SalesTableType)))
{
    // Code here will be run
}
 
// This is true as stt_j is a ''subclass'' of SalesTableType
if (SysDictClass::isEqualOrSuperclass(classidget(stt_j), classnum(SalesTableType)))
{
    // Code here will be run
}
 
// This is true as stt_j is an ''instance'' of SalesTableType_Journal
if (SysDictClass::isEqualOrSuperclass(classidget(stt_j), classnum(SalesTableType_Journal)))
{
    // Code here will be run
}
 
// This is FALSE as stt is NOT an instance or subclass of SalesTableType_Journal
if (SysDictClass::isEqualOrSuperclass(classidget(stt), classnum(SalesTableType_Journal)))
{
    // Code here will NOT be run
}

Monday 13 August 2012

Display Method explanation.

Introduction

A display method is not a physical field in a table but rather a method of displaying information from another table or source. It appears like a "normal" field and it can be used in forms and reports. For more information about display methods go to MSDN.

[edit] Usage

A display method can be created on either a table (in which case it is available for all forms using that table), or on the datasource of a specific form (in which case it is available only on that form).
Display methods must be created using a specific signature, which varies depending on the location of the method.

[edit] Display methods on tables

When declared on a table, display methods must be preceded with the keyword display and expect no parameters. The following example is a standard display method from the SalesTable table.
display CustName customerName()
{
    return this.partyTable_CustAccount().Name;
}

[edit] Display methods on datasources

When declared on a form datasource, display methods must have one non-optional parameter. The following example is from the PurchEditLines form in standard Ax 2012. The parameter is a buffer of the same type as that of the datasource on which the method is declared. It is essential as, when viewing a grid on a form, the method must know for which row the return value is to be calculated.
//BP Deviation documented
display ImageRes backOrder(PurchParmLine _purchParmLine)
{
    if (-InventTrans::backOrderQtyIssue(_purchParmLine.ItemId, _purchParmLine.InventDimId) > 0)
        return #Imageinfo;
 
    return 0;
}


[edit] Retrieving data from linked form datasources

When using a display method on a form datasource, it's possible to retrieve values from table fields in other datasources which are linked through an inner join to the current datasource. This is doing using the joinChild method and is illustrated in the example below.
This is the only reliable way to retrieve data from a joined datasource in a display method.
display public SalesQty remain(CustPackingSlipTrans _custPackingSlipTrans)
{
    if (isVersionArchived)
    {
        return _custPackingSlipTrans.joinChild().Remain;
    }
    else
    {
        return _custPackingSlipTrans.Remain;
    }
}


[edit] Limitations

A display method behaves like an ordinary field but has some limitations:
  • its data can not be changed (use edit method instead)
  • you can not filter and sort by display methods
If you need to sort and filter by a display method's data, there are the following workarounds
  1. Replace a display method with an ordinary stored field
  2. Replace a display method with inner joined table
The last is applicable if you have an often situation when display method simply returns a field value of the related table by mandatory field.
For example, you have a display method on the table named YourTable like the following:
//BP Deviation Documented
display EmplName emplName()
{
    return EmplTable::find(this.EmplID).Name;
}
If YourTable.emplID is mandatory, you can use an inner join instead of this display method:
  1. Place additional datasource on your form for EmplTable.
  2. Set LinkType property to 'InnerJoin'
  3. Add 'Name' field of the created EmplTable datasource to your Grid control or wherever else
If your original datasource is read only, your job is done. In the other case, when you try to add a new record to the datasource, you will see an error about mandatory fields of EmplTable. This error occurs because Ax tries to save joined datasource. To prevent such behaviour, you should
4. Override the write method of the EmplTable datasource with an empty implementation to prevent writing data to the table
public void write()
{
    // 'super' is commented out:
    // super();
}
5. Override the validateWrite method of this datasource to prevent error messages:
public boolean validateWrite()
{
    boolean ret;
    ;
    //ret = super();
    ret = true;
    return ret;
}
Now you can filter and sort your datasource by employee full name.

[edit] Caching

One significant side-effect of using display methods can be the impact on performance. Particularly when complex methods are used to calculate values being shown on grids, a visible slow-down in form performance can be experienced. This is largely due to the fact that the methods are often run repeatedly even when no reason is apparent and the values are unchanged.
To alleviate this, display methods on tables can be cached by using the cacheAddMethod method of the datasource object. To enable caching of a display method, call cacheAddMethod() from the init method of the datasource. This ensures that the display will only be calculated when necessary and can result in a significant performance improvement.
public void init()
{
    super();
 
    // Enable caching of the document handling display fields
    dirPartyTable_ds.cacheAddMethod(tablemethodstr(DirPartyTable, showDocHanIcon));
}
 
 
 
 
For more Information go with this link:http://www.axaptapedia.com/Display_method 

Thursday 9 August 2012

Showing the value of one field value on basis of another field on the dialog

The following code is for : When u select CustomerId in Field1 then it automatically takes the name of the selected CustomerId in field2...

public class ReportRun extends ObjectRun
{
     DialogField            dialogfield1,dialogfield2;
     CustAccount          custId;
     Name                   name;
}


 public Object dialog(Object _dialog)
  {
    DialogRunbase dialog = _dialog;
    ;
    dialog.caption('Customer information ');
    dialog.addGroup('Select CustomerId :');
    dialogfield1 = dialog.addField(typeid(CustAccount),"Cust Id : ");
    dialogfield1.value(custId);
    dialogfield2 = dialog.addField(typeid(Name),"Cust name : ");
    dialog.allowUpdateOnSelectCtrl(true);

    return dialog;
  }


public void dialogSelectCtrl()

{
     ;
     dialogfield2.value(custTable::find(dialogfield1.value()).Name);
}


boolean getFromDialog()
{
    ;
    custId   =   dialogfield1.value();
    name     =   dialogfield2value();
    return true;.
}

Display the data on the title bar?

Code to disply the emp_id on the title bar of the form

Path : MyEmplForm-->Data Sources-->MyEmplTable-->Methods-->active()


public int active()
{
    int  ret;
    ret  = super();
    element.design().caption(EmpLeaveDetails.Emp_Id);
    return  ret;
}


How to reverse a string in AX?

static void strReverve(Args _args)
{
str  s;
;
s =  'Test Info';
info(strReverse(s));
}

How to display date and time according to time zone ?

static void Job7(Args _args)
{
   ;
   //Current Date and Time according to time zone
   info(strFmt('%1',DateTimeUtil::newDateTime(systemdateget(),                                                                    timenow(),Timezone::GMT_CASABLANCA_MONTROVIA_REYKJAVIK)));

 //Todays Max Date and Time
info(strfmt("%1",DateTimeUtil::newDateTime(SystemDateGet(),Global::timeMax())));

}          

renaming a primary key. ?

I was given a task to perform renaming of Items in the InventTable.
In an environment that is to go live - so THERE WERE NO TRANSACTIONS OG STOCK LEVELS. If this has been the case we would have adviced the customer to live with it, as the renaming process potentially would have taken a very long time

Nearly 75% of the item numbers were named with 4 digits, the rest with 5.
The customer wanted only 5-digit item numbers.

How to do this in one go ?
A simple job is enough:


static void Job7(Args _args)
{

InventTable inventTable;
;

ttsbegin;
while select forupdate inventTable
where inventTable.ItemId LIKE "????"
{
inventTable.ItemId = "0"+InventTable.ItemId;
inventTable.renamePrimaryKey();
}
ttscommit;
}


or
Static void main updateIds(Args  args)
{
EmplTable  empltable;
Ttsbegin;
Select firstOnly forUpdate EmplTable where EmplTable.EmplId == ‘10001’;
If(emplTable.recId != 0)
{
emplTable.EmplId = ‘10101’(New EmplId);
EmplTable.renamePrimaryKey();
EmplTable.update()
}
Else
Info(‘employee not found’);
ttsCommit;
}


Wednesday 8 August 2012

How to convert the amount into words ?

display tempStr amountStr()
{
    if(netAmount <= 0)
    return   '-'+ ' ' + '(' + currCode + ') ' + numeralsToTxt(-(netAmount))+' '+'Only';
    else
    return   '(' + currCode + ') ' + numeralsToTxt_EN(netAmount)+' ' +'Only';
}

If a report attached to a form ,how can the report display the values of the selected one in form?

suppose i put my report on the  CustPackingSlipJour  form then i selected on e record,i want to display the information of that particular record only in my report then the following code helps    

public class ReportRun extends ObjectRun
{
    CustPackingSlipJour     externalCustPackingSlipJour;
}

public void init()
{
    element.initFromArgs(element.args());
    super();
}

void initFromArgs(Args args)
{
    if (args && args.dataset())
    {
        switch(args.dataset())
        {
               case tablenum(CustPackingSlipJour) :
                                        externalCustPackingSlipJour  =   args.record();        
        }
     } 
}

How to filter the data based on combo selection ?

DataDic-->Tables--->MedicineTable-->Fields

ItemId(string)
ItemExpired(enum)
ExpiryDate(date)

Medicine-->BaseEnums-->ItemExpired
ItemExpired :: Yes
                      No
                      All

MedicineInfoForm-->Methods-->classDeclaration

public class FormRun extends ObjectRun
{
    QueryBuildRange qbr;
}

 MedicineInfoForm -->DataSources--> MedicineTable -->Methods-->init()

public void init()
{
;
    super();
    qbr =    MedicineTable_ds.query().dataSourceTable(tablenum( MedicineTable )).addRange(fieldnum( MedicineTable ,ItemExpired));
    qbr.value(queryValue(ComboBox.selection()));
}

MedicineInfoForm-->Design--->Design-->Group : ItemExpired--->ComboBox:combobox-->Methods-->
modified()

public boolean modified()
{
    boolean ret;

    ret = super();

    if(combobox.selection()== ItemExpired::All)
    {
    qbr.value('');
    }
    else
    {
    qbr.value(queryValue(ComboBox.selection()));
    }

     MedicineTable_ds .executeQuery();

    return ret;
}

Explation on field fixed and related field fixed in table

Lets say you have ClothesTable and ClothesOrders.
ClothesTable has the following fields: ClotheId, Name and CollectionTypeId
MenClothesOrder has the following fields: OrderId, ClotheId, Qty  OrderId could be a number sequence and Qty entered manually bby the user.
CollectionTypeId has the following elements:
0 - Men
1 - Women
2 - Children
Example 1: Related Fixed Field
On MenClothesOrder we create a new relation to ClothesTable and specify the follwing two:
1. Normal = ClotheId to ClotheId (Best practice to specify this on the EDT) and
2. Related Fixed Field 0 = ClothesTable.CollecTionTypeId.
This shows that the lookup to the clothes table should show only clothes with the same ClotheId (point 1) AND clothes that are of type Men (point 2) because the our table deals with order for mens' clothes. We use 0 because Menis element 0 in the Enum.
Example 2: Fixed Field
This kinda works the other way round:
Imagine you have a ClothesOrders table (generic) and you have seperate tables for MenClothesTable, WomenClothesTable and ChildrenClothesTable. Fixed field says that the specified normal relation (on ClotheId) to MenClothesTable only works if the CollectionTypeId of the current record is set to 0 (Men) else the relation is disabled.

Learners blog

http://www.axaptapedia.com/Display_methodhttp://parimalajyothijp.blogspot.in/2012_01_01_archive.html
http://gotdax.blogspot.in/2009/12/batch-renaming-primary-key.html
http://dax-world.blogspot.com

















Tuesday 7 August 2012

displaymethod to get employee countryregionid

display AddressCountryRegionId SARdisplayEmployeeCountryRegion()
{
    DirPartyAddressRelationship         partyAddressRelationship;
    DirPartyAddressRelationshipMapping  addressRelationshipMapping;
    Address                             address;
    AddressCountryRegionId              ret;
    ;
    select  addressRelationshipMapping
    join partyAddressRelationship
    where partyAddressRelationship.PartyId == this.PartyId && partyAddressRelationship.IsPrimary &&
    partyAddressRelationship.RecId == addressRelationshipMapping.PartyAddressRelationshipRecId
    join address
    where address.RecId        == addressRelationshipMapping.AddressRecId &&
    address.DataAreaId   == addressRelationshipMapping.RefCompanyId;

    if(address)
    ret = address.CountryRegionId;
    else
    ret = '';
    return ret ;
}

A Fetch Method Override for A Date Range Data Retrival from Cust TRans Table as on ...

// #. A Fetch Method Override for A Date Range Data Retrival from Cust TRans Table as on ...
public boolean fetch()
{
    // 0. Declare Variables
    QueryRun qr;
    QueryBuildDatasource QueryBuildDatasource1;
    QueryBuildRange rangeTransDate;
    Boolean ret;
    CustTable custTable;
    CustTrans custTrans;

    // 1. A QueryRun object called qr is initialized with the active query of the report,
    qr = new QueryRun(element);

    // 2. Get DAtaSource from current element query
    QueryBuildDatasource1 = element.query().dataSourceTable(tablenum(CustTrans));

    // 3. A range for the customer transaction date field is added to Datasource
    rangeTransDate = QueryBuildDatasource1.addRange(fieldnum(CustTrans, transDate));

    // 4. Actusl Date Range Value is added to qr
    rangeTransDate.value(queryRange(systemdateGet() - daysBack, systemDateGet()));

    // 5. The range is locked, so the user cannot change it.
    rangeTransDate.status(RangeStatus::LOCKED);

    // 6. The transaction date range is added to the caption of the report.
    element.design().caption(strfmt("%1, %2", element.design().caption(), rangeTransDate.value()));

    // 7. At this point, the query is looped. The standard loop of the query and the printout of the
    // record is what the super() call in fetch() handles. Before the query is looped, there is a
    // check to see whether the dialogs for the query and the report are called.These are the two dialogs which are wrapped by RunBaseReportStd
    if (qr.prompt() && element.prompt())
    {
        // 8. query is looped
        while (qr.next())
        {
            // 9. Within each loop, the tables CustTable and CustTrans are initialized.
            // If no records are found, the loop breaks and the report ends.
            // If a data source has changed, a new record is found
            // and the record is printed using the send() method.
            custTable = qr.get(tableNum(CustTable));
            custTrans = qr.get(tableNum(CustTrans));

            if (!custTable)
            {
                ret = false;
                break;
            }
            // 10. Note the second parameter in the send() method.
            // The second parameter defines the level of the record. CustTable is on the first level of the query and
            // CustTrans is on the second level. This is important since, if it is not set correctly,
            // auto sums will not be printed.
            if (qr.changed(tableNum(custTable)))
            {
                 element.send(custTable, 1);
            }
            if (qr.changed(tableNum(custTrans)))
            {
                 element.send(custTrans, 2);
            }
        }
    ret = true;
    }
    else
        ret = false;
    return ret;
}
// 11.     ------Tactics of reports---
// In the fetch example, the query of the report was looped. The case could also be looping
// a WHILE statement, SELECT statement, or a combination of both. For each record
// looped in the query, you might want to select a record from a table which is not part of
// the query, or even build a temporary table to be printed. For each record to be printed,
// all you have to do is call the send() method
thnks

Monday 6 August 2012

Thursday 26 July 2012

Datamigration in ax 2009

http://shekhardiptiman.wordpress.com/2010/01/17/dynamics-ax2009-data-migration-%E2%80%93-import-multiple-addresses-of-vendors-customers-through-excel-template/#comment-148

Sunday 22 July 2012

Security in Ax

Four items control security in Microsoft Dynamics AX 2009:
• License codes include the company's purchased features. These
license codes enable the whole company access to those areas
purchased
• Configuration keys are used to enable or disable features in the
application. These keys control access for the whole company
• Security keys are assigned to user groups and control access to
features within Microsoft Dynamics AX 2009 at a user group level
• Record level security controls access to records in tables. This
means that different user groups can have different access to
different records in the same table

Lable Files

Lable Files:

In Ax, it is recommended to  use Lables instead of using static text.just because of re-usability and easy to modify when we need.
A label is the text that appears in the user interface. For example, the CustTable has a database field named CustAccount;however, the label in the application is Customer Account. This is done by defining the Label property for the
Extended Data Type That Is Used in the database field. Set the Label property at the Extended Data Type level to make sure it is inherited on all objects where Extended Data Type is used as a source.

When creating a label file, a reference is made to a label data file (.ald) in the file system that stores all the label files numbers and text. The label files are allocated numerically, such as @SYS120 and @SYS121. Label files are stored in the
application folder and use an extension of .ald. The .ald extension is an acronym for Microsoft Dynamics AX 2009 Label Data.

Working with lable file wizard:
 This wizard is used to create lable files .To create follow these steps,

 1. Navigate to Tools > Development Tools > Label, and select Label file Wizard. This opens the Label File Wizard.
2. Select the Create a new label file ID field. In this case, only create a new label file ID.
3. Create a label file ID named MBS. This is how the system references the new label file. This ID must be unique and contain only three letters.
4. Click Finish. Before writing any newly created label files, shut down Microsoft Dynamics AX 2009 and restart.


Lable File Editor:

Lable File Editor is used to add a new lable or  edit already existing lables and also to view available lables .

and to view or edit follow this steps,
1. Type the name of the label in the Find what: field and then click Find now. The system searches all available label names to check if the label exists.If it exists, as long as the label is highlighted, the user can reuse it by selecting Paste label.If the label does not exist, create a new one by pressing CTRL + N.
2. Click the Advanced tab.

When creating a new label, select which label file ID to create the new labels in.
The new label file ID created in the Label file Wizard is available in the drop-down
list.
1. Select one or more languages to view translations of the current label
or create translations of the new label.
2. Select the Auto Search function for the system to automatically start
to search when the label dialog opens.

Assign Labels to Objects:
When a new application object is created, a label must be assigned in the
properties. In some places the feature is called “Label” (for Extended Data
Types), and in other places it is called “Caption” (Design node of forms). Reuse
labels whenever possible by searching for the label, finding it in another label
file, and using it for the object.




Data migration and import excel to ax

http://community.dynamics.com/product/ax/axtechnical/b/daxit/archive/2010/01/17/dynamics-ax2009-data-migration-8211-import-multiple-addresses-of-vendors-47-customers-through-excel-template.aspx

Wednesday 11 July 2012

Where do we find this layes in AOT?

To select to view the application object layers for any object in the AOT:
1. Select Tools > Options.
2. On the Development tab click the drop-down box next to the
Application object layer field.


We have different options to select ,those are,

• Show no layers - No objects are labeled with a layer indicator
• Show all layers - All objects are labeled with layer indications for
all layers in which they exist
• Show highest layer - Shows only the highest layer where the object
has been modified
• Show corrected layers - Shows only objects modified in the current
layer or higher and labeled with indication of the highest layer
• Show all from corrected layers - Shows only objects modified in
the current layer or a higher layer, with an indication of all layers of
modification

Introduction to Ms Dynamics Layered Architecture.

Microsoft Given a seperate architecture which is more flexible to update and customize the application called as layering.In this architecture we find several layers based on their security and functionality.This looks like the following.


The Assumption behind this architecture is to secure the basic application and also the use of This is,
   • Any user of the Microsoft Dynamics AX 2009 application can
     customize the Microsoft Dynamics AX 2009 application
   • The standard application is never overwritten
   • Deleting an object removes it either in the current layer or the layer
     above if the object exists in a higher layer. Every time an object is
     opened, the system automatically searches for and uses the object
     files needed in the highest layers first

Each layer is saved in a separate file that has an extension of .aod. For example,
Axsys.aod is the SYS layer. The aod extension is an acronym for Application
Object Data file.
The layers are designed for different Microsoft Dynamics AX 2009 developer
groups. Three groups have an interest in adding or modifying application objects:
        • Microsoft Business Solution Developers who create the
          standard application
       • Business partners and developers who want to enhance Microsoft
         Dynamics AX 2009
      • Microsoft Dynamics AX 2009 end-users

Introduction to AOT(Application Object Tree)

Introduction to AOT(Application Object Tree).

AOT (application object tree) ,is a tree stuctured window ,in which we have entire Ax objects .in



Basic Introdution or Working With Forms.

Creating a record:

Within each module tasks can be performed such as creating new records. For
example, in the Accounts Receivable module customers can be added and sales
orders created.
1. Open the customer form located in the Accounts Receivable module.
(Accounts Receivable/Common Forms/Customer Details)
2. Press CTRL + N to create a new blank row in the customer form.
3. Enter the following data into the fields:
o Customer account: 4099
o Name: Wholesale Foods
o Customer group: 30

The data is automatically saved into the database after moving away from the
new record


Sorting Records:
When working with data in a form it is sometimes necessary to change the sort
order of the data to find specific information more easily. Records can be sorted
in a form using three different methods.
1. Click the header of the sorting column. Records are sorted in
descending order. Clicking the header again sorts in ascending order.
2. Right-click on a field in the column to sort. The shortcut menu
appears with the options to sort in ascending or descending order.
3. Sort records by selecting either Sort Ascending or Sort Descending
from the Edit/Sort menu in the menu bar.
o To remove the sort order, click the Remove
filer icon.

Filtering of Records:

Sorting works well when working on a small set of data. However, to work
efficiently with large amounts of data, filter the data to work with a specific
subset of information.
There are three ways to filter data in the user interface:
• Current content of a field
• Using an inquiry dialog where the criteria for the filter is specified
• Filter by grid

To remove this filter, click the Remove Filter icon on the toolbar.

Finding Records:

Use the Global Search option to search for information across selected tables.
There are three ways to start a Global Search. From the “Menu Pane:”
• Select the ‘Find…’ option on the Edit menu
• Select the Binocular icon from the toolbar
• Press Ctrl + F

Basic Navigation

Basic Navigation includes 1)navigation pane and 2)area pane

When first opening Microsoft Dynamics AX 2009, the Navigation Pane appears.
This menu contains all the purchased modules in the license code. From here, the
user can browse to any module in Microsoft Dynamics AX 2009.

Area Page:
An Area Page is a Microsoft Dynamics AX 2009 navigation page that displays
menu items that link to list pages, content pages, forms, reports, classes, jobs, and
queries. To view an area page, click a module button in the Navigation Pane. The
area page opens in the client content pane that is automatically generated using
the menu information for that module.

X++?

X++ is the object-oriented programming language that is used in the MorphX
environment

MorphX

The MorphX Development Suite is the integrated development environment
(IDE) in Microsoft Dynamics AX 2009 used to develop and customize both the
Windows interface and the Web interface. An IDE integrates development
functions such as designing, editing, compiling, and debugging within a common
environment.
With MorphX, common operations such as building or modifying forms, menus,
and reports are done using drag-and-drop techniques with little or no coding.

IntelliMorph

IntelliMorph is the technology that controls the user interface in Microsoft
Dynamics AX 2009. The user interface is how the functionality of the application
is presented or displayed to the user. The same functionality can be displayed on
multiple platforms or devices that use the same application code; for example,
through the Web or through Mobile devices.
IntelliMorph controls the layout of the user interface and makes it easier to
modify forms, reports, and menus.

Application Object Tree (AOT)

The Application Object Tree (AOT) is a tree view of all the application objects
within Microsoft Dynamics AX 2009. The AOT contains everything needed to
customize the look and functionality of a Microsoft Dynamics AX 2009
application.

Tuesday 10 July 2012

What are the methods which gets affect when posting a Sales order or Purchase order?

What  are the methods which gets affect when posting a Sales order and Purchase order?

Ans:

Whether It is PO or SO first the FormLetter class will be called and then based on whehter it is a PO or SO

the PurchFormLetter and SalesFormLetter Classes will be called. and then based on the stage of posting it will call different classes.

Eg: If you are positng a PO invoice PurchFormLetter_invoice class will be called.

If you wan to know the what are all the different classes and methods that are called during SO/PO posting - put a break point in FormLetter - new method



cust, cust,vendinvoicejour has some initfromsalestable method.the form letter class call this method and it will insert the header level records(sales table) to cust invoice jour and footer level(saless line) records to cust invoice trans(here it will call initfromsalesline)
and

Thursday 21 June 2012

AX Architecture:


AX Architecture:

  As comman technologies like java,.net and any technology now a days is based on 3 tier.This ax also having a 3-tier .

  • Client
  • Server(Here we have one inbuilt server called as AOS(Application Object Server) )
  • Database(It may be Sqlserver and in earlier versions it also supports for Oracle)

What are the features of AX?

What are the features of AX?
  •  A highly integrated design between functional areas such as
    resource planning, sales, and manufacturing
  •  Dimension-based system for Manufacturing and Financial
    modules
  •  Advanced features such as Forecasting and Master Planning are
    available.
  •  Multicurrency and Multilanguage capabilities

Where we find this ERP?

Where we find this ERP?

• Manufacturing
• E-business
• Wholesale
• Services industries

  


What is Dynamics Ax?

What is Dynamics Ax?
  • Dynamics Ax  is an  ERP(Enterprise Resource Planning),Which Deals with all the department functionalites and makes them into one system.In simple terms it will handle all the enterprise activites with accurate and systematic way. 
  • Dynamics AX 2009 is a customizable, multiple-language, and
    multiple-currency Enterprise Resource Planning (ERP) solution. It supports around 45 languages .

Dynamics AX Tutorial For Beginners

Dynamics AX Tutorial For Beginners