CrossCompany Vs ChangeCompany In Dynamics Ax 2012

Hi Everyone today i would like share information regarding how to retrieve data from Selected companies or from a specified company by using Keywords known as CrossCompany and ChangeCompany in Dynamics Ax, with a simple example.  

CrossCompany :  By using this keyword we can retrieve data from multiple selected companies or from all companies.
Example:-  We'll be using the well known demo data table (i.e, CustTable).

                    CustTable                 custTable;
                    Container                  con;
                 // Assigning the required Companies to the container 
                    con = ["CEU","DAT","CEE"];
                // CrossCompany:Object is the syntax for using CrossCompany keyword
                    Select crosscompany:con custTable;
                    
info( strfmt("%1",custTable.accountnum));

ChangeCompany : By using this keyword we can change company any time and retrieve data from specific companies. 

For Easy Understanding: Let say i'm in the CEU Company and i would like to get the data belonging to the CEE Company. Then i would Prefer to Use ChangeCompany Keyword.

Example:-
                    CustTable                 custTable;
                    Select * from custTable;
                    
info( strfmt("%1",custTable.accountnum));
//Accessing the data from a specified company by using the ChangeCompany Keyword
// changecompany("Company Name")  is the Syntax for ChangeCompany Keyword.
                    changecompany("CEE")
                    {
                        
custTable = null
                        Select * from 
custTable;
                        
info( strfmt("%1",custTable.accountnum));
                     }
// Retrieving from another selected Company
                    changecompany("CEEU")
                    {
                         
custTable = null
                         Select * from 
custTable;
                         
info( strfmt("%1",custTable.accountnum));
                     }                    

Proud To Be a DAX Developer :-)

What Is The Difference Between OCC and PCC in Ax 2012

Optimistic Concurrency Control (vs) Pessimistic Concurrency Control

Pessimistic Concurrency Control :
                                                    On updating the data, the record gets locked and no one else can access that record for updating. It becomes a read-only record till the lock is released. Once the lock gets released, the record can be locked again and get updated for a different user.

Optimistic Concurrency Control :
                                                    This allows multiple user to open up the same record for updation . Record gets locked only while updating the record. This is the most preferred way of locking for the web application.

Proud To Be a DAX Developer :-)

Calling Sequence Of Methods In FORM Level in Ax 2012

Hi Every one, today i would like to share my knowledge on Calling Sequence Of Methods in Form Level. Each form has a set of standard methods. You can override these methods to change the behavior of the form, respond to user interface events, and customize the appearance of a form.There are also methods on each form data source and on each form control.
Below scenarios gives the information of  method calls in the form level 
  1. Opening the Form.
  2. Creating/Updating/Deleting the record in the Form.
  3. Closing the Form.

What's The Difference Between Passing By Reference & Passing By Value?

Hi Everyone,
Today i would like share information about the topic "Pass by value & Pass by reference". This is topics is very confusing for the beginners, so i have come up with an simple example(definition) to make you understand. Source

Example Scenario : Let Say I want to share a web page with you.


Passing By Reference :
  • If I tell you the URL, I'm passing by reference. You can use that URL to see the same web page witch I can see. 
  • If that page is changed, we both see the changes. 
  • If you delete the URL, all you're doing is destroying your reference to that page - you're not deleting the actual page itself.
Passing By Value :
  • If I print out the page and give you the printout, I'm passing by value
  • Your page is a disconnected copy of the original. 
  • You won't see any subsequent changes, and any changes that you make (e.g. scribbling on your printout) will not show up on the original page. 
  • If you destroy the printout, you have actually destroyed your copy of the object - but the original web page remains intact
Proud To Be a DAX Developer :-)