Monday, 20 June 2016

Surrogate Key, Replacement Key, Alternate Key in Ax 2012

Surrogate Key
                              surrogate key is the auto-generated primary key for a table in the database.
The surrogate key is linked to the already existing RecId field within any table. 

  • The surrogate key is a unique 64-bit integer value that is mandatory for the table and cannot be changed or have duplicates
  • It's something created by the database itself, like an identity column, however in Ax it's managed by the kernel.
eExample  https://community.dynamics.com/ax/b/axrajdipdas/archive/2013/04/16/how-to-create-and-implement-of-surrogate-keys-in-ax2012
      
      Replacement Key
             
            While a surrogate key is great for lookup and database performance, it is not useful for the end user because it gives no indication of the table’s purpose, or what related tables it is linked to. For this reason AX 2012 has added the ‘Replacement Key’ index property for tables. 
              The replacement key index is a dropdown of alternate keys that have been specified for the table. There can be any number of alternate keys for a table but only a single replacement key. More than one field can be specified under a replacement key, and it is these fields that will be displayed to the end user on a form instead of the surrogate key field.

     Alternate Key
               A table can have any number of alternate keys. An alternate key may be a natural key or a single field primary key used in foreign or primary key relations with other tables. In either case, to set one, the user must create a new index and then set AllowDuplicates to “No” and AlternateKey to “Yes”. If AllowDuplicates is not set to “No” then AlternateKey should be greyed out and uneditable.










How to get Popup for a Particular Field of table based on Related table in ax 2012

How to Setup Batch Job in Ax 2012

1. Click Area Page node: Administration -> Setup -> Server configuration.

2. Make sure the selection is changed in table Server Configuration to:

3. Change Is Batch Server from 'No' to 'Yes'.

4. Close the Server configuration form.

5. Click Area Page node: Basic -> Inquiries -> Batch job.

6. Create a new record in the Batch job form.

7. Change Job description from '' to 'Test'.

8. Change Created by from '' to 'Yourname'.

9. Change Company accounts from '' to 'Your Company'.

10. Save the record in the Batch job form.

11. Click the View tasks button.

 
Form name: Batch tasks

12. Create a new record in the Batch tasks form.

13. Change Task description from '' to 'Test'.

14. Change Company accounts from '' to 'DAT'.

15. Change Class name from '' to 'Select The Class Name'.

16. Change Run location from 'Client' to 'Server'.

17. Right-click the field to go to the main table.

Form name: Batch group

18. Create a new record in the Batch group form.

19. Change Group from '' to 'Test'.

20. Change Description from '' to 'Test'.

21. Save the record in the Batch group form.

22. Switch to the Batch servers tab on the Batch group form.

23. Click the < button(Select the AOS server).

24. Save the record in the Batch group form.

25. Close the Batch group form.

26. Change Batch group from '' to 'Test'.

27. Save the record in the Batch tasks form.

28. Close the Batch tasks form.

29. Click the Recurrence button. 

30. Change TimezoneId from '(GMT+02:00) Harare, Pretoria' to '(GMT+05:30) Chennai, Kolkata, Mumbai, New Delhi'.

31. Change Count from '10' to '2'.

32. Click the OK button.

33. Save the record in the Batch job form.

34. Close the Batch job form.

Tuesday, 14 June 2016

Hide Unwanted modules in Microsoft AX 2012


select the Configure Button which is shown in the bottom of the Modules.





>> Click Navigation Panel Options







































>> By using the Arrow button you can change the location of the module in AX 2012.

Monday, 13 June 2016

Vendors Merging and Customers Address Merging in Ax 2012

CustomerAddress Merge
static void Raj_CustomerAdressMerge(Args _args)
{
    CustTable custTable;
    DirParty dirParty;
    DirPartyPostalAddressView PostalAddress, PostalAddressDest;
    ;

    custTable = CustTable::find('R001'); //From Customer Address

     select PostalAddress
        where PostalAddress.Party == CustTable.Party;
   
        buf2Buf(PostalAddress, PostalAddressDest);
        PostalAddressDest.Party = CustTable::find('R002').Party; //To customer Address
        PostalAddressDest.IsPrimary = NoYes::No;
        PostalAddressDest.LocationName =  PostalAddress.LocationName;
        dirParty = DirParty::constructFromCommon(custTable);
        dirParty.createOrUpdatePostalAddress(PostalAddressDest);

}



VendorsMerging

static void VendAccountMerge(Args _args)
{
      VendTable            vendTable;
      VendTable            vendTableDelete;
       PurchJournalAutoSummary           jourSummary;
      #define.vend('14063')
      #define.vendDelete('14437')
     ;

     ttsbegin;
    delete_from jourSummary where jourSummary.VendAccount == #vendDelete;
    select firstonly forupdate vendTableDelete where vendTableDelete.AccountNum == #vendDelete;
    select firstonly forupdate vendTable where vendTable.AccountNum == #vend;
    
    vendTableDelete.merge(vendTable);
    vendTable.doUpdate();
   //vendTableDelete.doDelete();
     ttscommit;

}