Saturday, 20 April 2013

Restrict duplicate records in AX

In case you have a requirement where you are suppose to restrict the duplicate records.

E.g. :


If in case you have 4 fields.
And you require that any two same record values in the four or less columns should not repeat.

You don't want same record(same combination) to be saved twice.



Column:       A            B          C             D
                 amit      60       India          emp
                  yatish       60       India          emp
                 amit         60       India          emp                ****this record should not be saved


Solution :

1) Make new index to the table.
2) Add the fields that you want to be added to the restricting combination.(Here all 4)
3)Go to properties and set 'AllowDuplicates' to "No".

This will restrict you from saving any duplicate combination in the table.

Note: In case you need only A & B column without repeat then add only A & B fields to index.

Delete all transaction data for a specific company in AX

I have noticed that sometimes we might need to delete all the transaction data for a particular company without altering the configuration data.This is possible in AX.

1)Login into AX in the company for which you want to delete the transaction data.
2)Go to AOT.
3)Open class SysDatabaseTransDelete
4)Run it and Click 'YES' to delete all the transaction data in the current logged in company.

This might take few moments depending on the amount of data.

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.