Thursday 22 November 2012

Exceptions in Dynamics AX 2012



Exceptions:

       
A Situation in which the flow of a program is interrupted is called exception . A program must handle them For example: If a user requests a record to be fetched and that record doesn't exists then in that case system must throw an exception. There are many types of exceptions thrown depending upon it's cause . All of them can be caught so it's a developer's decision to decide which exceptions must be handled by the system.

Some common exceptions are listed below:







Try , Throw ,Catch & Retry Statements :


Try: 

       These statements indicate the start of the block of code that you are going to handle with X++ Exception handling system . Any exception thrown in this block can be caught in the associated catch statements.

Throw:

       These statements are used to explicitly throw an exception that can be caught by the Catch statement.

Catch:

       These statements define what code is going to be executed in case of an exception being thrown . These statements come after the Try statement. It is not necessary to catch each try statement But each Try statement must have a corresponding Catch statement.

Retry:

       These statements tell the system to go back to the Try statement and attempt to execute the code again , any data loaded before the Try statement remains the same where as any data loaded after the Try statement will be refreshed.

Optimistic Concurrency Control ( OCC ) :


It is a performance enhancing function within Dynamics AX . It assumes that a record retrieved from the database is not updated , until it is proven to be updated by the database which means that in case of updating a record the system compares the rec Version field of the record with the actual record in the database. The rec Version field is updated each time a record is successfully updated. There are two exceptions thrown in case of a record been updated in a transaction using Optimistic Concurrency Control.


 Handling Exception in Code:





























In the above example in the Try block an exception is thrown if the user lefts any dialogue field empty or if the AccountNum already exists. This Exception is then caught in the Catch Block later in the code .

I believe it was helpful.

  

Tuesday 6 November 2012

Dynamics Ax 2012 Security


SECURITY :


       Role based security defines the access to Microsoft Dynamics Ax 2012 application and data . It relates to the job role that an end user has with in an organization . The role includes the duties, privileges and permissions required by that role.
  
        The maintenance of roles and duties is typically undertaken by the system administrator  where as the maintenance of privileges and permissions is performed by the developer.

BASIC CONCEPTS:


 Security Roles:

          It depicts the behavior that a person in an organization can play. A Security role includes one or more duties.
   

 Duties:

       A responsibility to perform one or more tasks. A duty requires one or more privileges in order to perform that duty.

 Privileges:

         The access required to perform a duty. A privilege includes one or more permissions.
  

 Permissions:

         The level of access associated with one or more securable objects that are required to perform the function associated with an entry point.

 Designing Role Based Security:         

  1.  First of all we need to set up a new user .
  2.  The end user is assigned one or more security roles.
  3.  Security role is assigned one or more duties.
  4.  Duties require one or more privileges.
  5.  A privilege contains one or more permissions.
Have a look at this example:



According to the above diagram the Accounts Receivable Manager Role has the duties of maintaining customer master and to inquire chart of accounts for which it requires privileges (i.e) delete access to customer form display menu item and create new address action menu item But in order to know the level of access it requires permissions on that form  (i.e) Read , Update , Create , Delete. 

I believe it was helpful ..

For further reading you can refer other useful links like:
  

Dynamics Ax 2012 FactBoxes


FactBoxes:

              A FactBox is used to display the data related to the currently selected record in the list page.
  
 There are three types of  Factboxes :

1) InfoPart.
2) FormPart.
3) Cues.

  • InfoPart: 
 It is very simple to create and can display limited number of controls. It has its own data source and can also be displayed in Enterprise Portal.  

  • FormPart:                                         

             It is a link to a Form and can  have the same controls as an standard form .It is displayed in the FactBox Section , So adding too many controls can crowd the form.

  • Cues:

               It is used to display the Count of number of records related to the current record in the list page.
                           
 For Further information you can read from here:
               http://msdn.microsoft.com/en-us/library/gg847986.aspx