Thursday 14 March 2013

Lookup in AX

This is a small tutorial to setup lookup in ax.


1)Create a new enum - Trix_Enum with 3 enum elements - ele1,ele2 & ele3

2)Create a new EDT  by name : Trix_EDT_Id

3)Create a new table Trix_table with 4 fields :
   Trix_Id[datatype - Trix_EDT_Id]
   Trix_Name[datatype - Name]
   Trix_Type[datatype - Trix_Enum]
   Trix_amount[datatype - AmountMST]


4) Go to AOT> EDT> Trix_EDT_Id
    Expand the relation node and create a Normal relation.
    Go to properties and select the source table in "Table" & source table field in "RelatedField"(E.g.Trix_Id)
    Save the changes.

5)Go to the source table from which data should be lookup.
   Open the AutoLookup field group.
   Add the fields that need to be looked up.(E.g. Trix_Name,Trix_amount)

6)Now use the EDT "Trix_EDT_Id" as edt for any new field.The new field will look up the source         table(Trix_table) columns.(E.g. Here Trix_Id,Trix_Name,Trix_amount)

7)Incase of Related field fixed relation it works as a where clause/condition and should be given on enums.
   Go to AOT> EDT> Trix_EDT_Id
   Expand the relation node and create a Related field fixed relation.
   Go to properties and select the source table field in "RelatedField"(E.g.Trix_Type) & enum value(E.g. 0,1,2) in "Value".
    Note: The condition is ANDed with the normal relation.

Wednesday 13 March 2013

Important functions in AX

Some useful Functions:

curuserid();
Function : Returns the user id of the current user.

curext();
Function : Returns the current logged in company.

today();
Function : Returns machine's current date.

systemdateget();
Function : Returns system application's current date.

System does not support setup 'continuous' of number sequence

Solution:

Some functions need to be called with a transaction processing.So just try using ttsbegin and ttscommit for the fuction call which is issuing the error.
Mostly issued while using the number sequence.

E.g:

ttsbegin;

// statements giving error

ttscommit;

Cannot select a record in (Table_name).Field_name: . The SQL database has issued an error.

Cause:
There is a sync issue with the table on application and the database.

Solution:
Go to   /Administration/ SQL Administration
Select the the table which is giving the error and press the button 'Table actions' > 'Check/Synchronize'.
If this does not fix the issue try 'Index actions' > 'Reindex'

Tuesday 12 March 2013

"Journal has already been posted and, consequently, is not open"

Cause:

The cause of this error is when you are trying to post a Journal which is already posted.This mostly happens when you are trying to post using X++ code.

Check if you are passing new record(LedgerJournalTable) to Class LedgerJournalCheckPost everytime you call it for posting.

First time you call the class the selected record gets posted but second time it is stopped in the validation process.As the record is already posted once.

Bound,Unbound and Calculated Controls

Bound controls:
Bound controls are linked to the table and the information/data is saved(inserted/updated) to the database.Any control which has a datasource and a datafield in its properties is a bound control.

Unbound Controls:
UnBound controls are not linked to the table and information will not be saved(inserted/updated) to the database.
Use unbound controls to display pictures and static text.

Calculated controls:
Calculated method uses a method as the data source.
Usually display and edit methods are used in the data source of such controls.

Box Class

Boxes are mostly used for confirmation from the end user before executing business logic.


There are many Box methods like:
- info, warning, stop, yesNo, OkCancel etc

Class which is used to create Boxes is "Box" and all the methods are static methods in this class.
Box can be useful to beginners who are not used to the Debugger in AX as it can help them trace the path of code execution.

Here is a example job for Box class:
static void Trix_Box(Args _args)
{
    ;
    Box::info("This is an info box");
 
    Box::warning("This is a warning message");
 
    Box::stop("This is stop");
 
    if (Box::yesNo("Would you like to proceed", DialogButton::No, "A box example", "bottom text")
        == DialogButton::Yes)
        {
            info("Processing...");
        }
        else
        {
            throw error ("Process aborted");
        }
     
     
   info ("Process Complete");
}