Friday, October 12, 2012

All X++ Editor shortcuts at one place in AX 2012

All X++ Editor shortcuts at one place in AX 2012


Breakpoints
Shortcut key
Remove all breakpoints. CTRL+SHIFT+F9
Insert or remove a breakpoint. F9
Enable or disable a breakpoint. CTRL+F9
Open the Breakpoints dialog. SHIFT+F9
   
Compilation and Help
 
Open the Scripts menu. Scripts icon
Open Help. F1
Show method parameter help. CTRL+SHIFT+SPACEBAR
Execute the current job. F5
Compile. F7
Compile and close a method. F8
Stop method execution (break). CTRL+BREAK
Insert a file. CTRL+ALT+H
Delete
 
Delete from the cursor to the end of the line. Use SHIFT+END to select to end of line and then DELETE
Delete word to the right of the cursor. CTRL+DELETE
Delete the word to the left of the cursor. CTRL+BACKSPACE
Delete the current line. CTRL+X (with cursor in line, no selection)
   
Edit
 
Insert script. <SCRIPT NAME>
Insert document header. ///
Comment selection. CTRL+E, C
Uncomment selection. CTRL+E, U
Convert selection to lowercase. CTRL+SHIFT+U
Convert selection to uppercase. CTRL+U
Display all methods and properties for a selected class. CTRL+SPACEBAR
Copy selection. CTRL+C (with text selected)
Copy line. CTRL+C (with cursor in line, no selection
   
Find and Replace
 
Open the Find dialog. CTRL+F
Open the Replace dialog. CTRL+R
Start incremental search.. CTRL+I
Move to next incremental search match in method. CTRL+I
Reverse the incremental search direction. CTRL+Shift+I
Remove a character from the incremental search string. BACKSPACE
Stop the incremental search. ESC
   
Go to
 
Go to a specific line. CTRL+G
Go to the next page. PAGE UP
Go to the previous page. PAGE DOWN
Go to the top of the code. CTRL+HOME
Go to the bottom of the code. CTRL+END
Go to the start of line. HOME
Go to the end of line. END
Move one word to the left. CTRL+LEFT ARROW
Move one word to the right. CTRL+RIGHT ARROW
Go to the method definition. F12
Go to the next error message. F4
   
Look up
 
Look up a label. CTRL+ALT+SPACEBAR
Show label text. CTRL+L
Look up a definition. F12
Show the syntax of a method or property. CTRL+SPACEBAR
   
Save
 
Save the selected text to a separate file. ALT+S
Close the current TAB, discarding all changes since the last save. F6
Close and save the current code editor window. F8
Close the current window. CTRL+F4
   
Select
 
Select all. CTRL+A
Cancel a selection. ESC
Select columns. ALT+MOUSE SELECT
Select a line. ALT+L
Select one word to the left. CTRL+SHIFT+LEFT ARROW
Select one word to the right. CTRL+SHIFT+RIGHT ARROW
Select text from the cursor to the start of the line. SHIFT+HOME
Select text from the cursor to the end of the line. SHIFT+END
Select the previous page. SHIFT+PAGE UP
Select the next page. SHIFT+PAGE DOWN
Select text from the cursor to the top of the code. CTRL+SHIFT+HOME
Select text from the cursor to the bottom of the code. CTRL+SHIFT+END
Indent the selected text. TAB
Remove indentation. SHIFT+TAB
Select area/column/block ALT+MOUSE SELECT
Cancel selection ESC
Show white space CTRL+SHIFT+S
   
Undo and Redo
 
Undo the last action. CTRL+Z (previous ten actions)
Redo the last action after an Undo. CTRL+Y (previous ten actions)

How to get Table field properties through X++ Code


Here is a job of how you can do that:

 

static void Job5(Args _args)

{

    TreeNode            vendFldsRoot = treeNode::findNode(@"\Data Dictionary\Tables\VendTable\Fields");

    TreeNodeIterator    vendFldsIterator;

    TreeNode            vendFlds;

    NoYes               visibleProp;

    ;

 

    vendFldsIterator = vendFldsRoot.AOTiterator();

    vendFlds = vendFldsIterator.next();

 

    while(vendFlds)

   {

        if(vendFlds.AOTgetProperty('Visible') == 'No')

        info(strfmt("field %1", vendFlds.treeNodeName()));

        vendFlds    =   vendFldsIterator.next();

    }

 

}

 

Thanks,
Swapna.

Thursday, October 11, 2012

Transaction integrity checking- TTS in Axapta

The database transactions in any system should be consistent and should have predictable results. There should be integrity or check whether we successfully completed our transaction. If the transaction causes and error/exception it must be able to roll back to the state before starting the transaction.
Below statements are used in X++ for the Transaction integrity checking:
  1. TTSBEGIN - This indicates beginning of a transaction.
  2. TTSCOMMIT - This indicates the successful completion of a transaction with out any errors and exceptions
  3. TTSABORT - This statement is used as an exception when something goes wrong in the trasaction. This statement rolls back the database transaction to the state before TTSBEGIN. This statement is automatically called by the system in case of exceptions.
AX keeps track of the Nested TTS statements by using a level counter which is incremented by one for each TTSBEGIN and decremented by one for each TTS COMMIT

Example for usage of TTS:
Custtable custTable;
;
ttsBegin;

select forUpdate custTable where custTable.AccountNum == '4000';
custTable.NameAlias = custTable.Name;
custTable.update();

ttsCommit;
 

Tuesday, October 9, 2012

Database Model Diagrams in Axapta

I am going to explain how to easily get Database Model Diagrams for set of tables you wish to in Axapta.
Here are the steps to do:
  1. Create a new Shared project.
  2. Drag all the tables you need for the datamodel diagram in to your project.
  3. Click Tools > Reverse Engineer. The Reverse Engineering dialog box displays
  4. In the dialog box, select ERX ER Data Model.
  5. Select the project you just created
  6. In the file name give correct path of windows location where you wish to create the .erx file.
  7. Click OK.
  8. Now go to Microsoft Visio
  9. Click File > New > Software and Database (or Database if you are using Microsoft Office Visio 2003) > Database Model Diagram
  10. On the Database menu, point to Import, and then click Import Erwin ERX file.
  11. In the dialog box, click the Browse button, navigate to the location of the .erx file that you generated from the Reverse Engineering tool, select the file, and then click OK.
  12. You will now see that tables you selected appear in Tables and Views window.
  13. Drag items from the Table and Views window onto the diagram surface. After you have added a table to the diagram, you can right-click the table in the diagram, and then click Show Related Tables. This will add all the related tables from the Tables and Views window that are not already in the diagram
You can then modify the diagram as you wish for the ease of understanding like you can delete the unecessary fields.

Exception types in AX2012


Exceptions in AX 2012

AX 2012 has an Exception system enum which cannot be modified. That means we cannot add any new exception types. AX throws these exceptions in following conditions.

Here are these types:

Exception Description

 

Info: Thrown when a message is sent to infolog. Developers should not throw this exception manually.

Warning: Thrown when something illegal has occurred which is non-fatal

Deadlock: Thrown when a database deadlock has occurred. Like when many transactions are waiting for one another.

Error: Thrown when something fatal error has occurred stopping all the transactions.

Break: Thrown when the user has pressed CTRL + C or Break during run time.

Internal: Thrown when something goes wrong with the development in run time.
DDEerror: Thrown when an error occurs in the DDE system class. DDE is Dynamic data exchange which is a inter process communication to exchange data between different applications.
Sequence: ????
Numeric: Thrown when a error occurs in a numerical functions.
CLRError: Thrown when an error occurs during the use of common language runtime functionality.
CodeAccessSecurity:  Thrown when a problem occurs during the use of CodeAccessPermission.demand.
(CodeAccessPermission.demand is used to check whether the permissions required to access an API is granted to the calling code.
UpdateConflict: Thrown when a record is updated using Optimistic concurrency control when the recVersion of buffer and database are not equal. The trasaction can be retried. (Use a retry statement in the Catch block)
UpdateConflictNotRecovered: Thrown when a transaction is not completed which is using Optimistic concurrency control. The transaction cannot  be retried.
 

 

Thursday, October 4, 2012

Swapna Kallu's Blog: InventDimGroupSetup in AX2012

Swapna Kallu's Blog: InventDimGroupSetup in AX2012: Here is a piece of code how you can get to know the dimension is active on your product or not in AX 2012. static void DimensionTest(Arg...

InventDimGroupSetup in AX2012


Here is a piece of code how you can get to know the dimension is active on your product or not in AX 2012.

static void DimensionTest(Args _args)
{
    InventTable inventTable;
    InventDimGroupSetup inventDimGroupSetup;
    InventDimGroupFieldSetup inventDimGroupFieldSetup;
    ;
    select * from inventTable where inventTable.ItemId == "Test";
    inventDimGroupSetup = InventDimGroupSetup::newInventTable(inventTable);
    inventDimGroupFieldSetup = inventDimGroupSetup.getFieldSetup(fieldNum(InventDim, WMSPalletId));
    if(inventDimGroupFieldSetup.isActive())
    info("Its active");
   
}