Monday, November 26, 2012

DictEnum class in AX2012


The DictEnum class obtains meta-information about the base enumeration enumerations in the AOT.
This can be used when you want to access an enum properties or values at run time.
Can be initialized as below:
DictEnum            dictEnum;
dictEnum = new DictEnum(enumNum(DMFEntityType));

Now we are ready to all properties of enum DMFEntityType

dictEnum.value2Label(i)- Retrieves the label of a specified enumeration value. ‘i’ being the enumeration value

dictEnum.index2Label(i) - can be used in a for loop where ‘i’ being the iterator index value.  This will retrieve the label of the enumerator at specified index.
dictEnum.index2value(i) - can be used in a for loop where ‘i’ being the iterator index value.  This will retrieve the enumerator value of the enumerator at specified index.

RecordInsertList class in AX2012


The RecordInsertList class allows to insert multiple records in to database.

new() - Creates a new object to hold records for insertion into the database.
add() - Adds a record to a RecordInsertList object for subsequent insertion into the database
insertDatabase() -  Inserts all records, that have not already been inserted, in the current 
RecordInsertList object.  


The following example uses the RecordInsertList class to copy records from one table buffer to another.
void copyBOM(BOMId _FromBOM, BOMId _ToBOM)
{
    RecordInsertList BOMList;
    BOM BOM, newBOM;

    BOMList = new RecordInsertList(tableNum(BOM)); 

    while select BOM
    where BOM.BOMId == _FromBOM
    {
        newBOM.data(BOM);
        newBOM.BOMId = _ToBOM;
        BOMList.add(newBOM); 
     }
    BOMList.insertDatabase(); 
}

Tuesday, November 13, 2012

Data Migration framework User guide and download

Data migration framework user guide:
http://technet.microsoft.com/en-us/library/jj225591.aspx

You can download the tool at Information source. Login using your partnersource account to download.
You can also look at the demo video on the link.

Friday, November 9, 2012

Importing conflicting models in AX 2012


Import an .axmodel file using Microsoft dynamics AX2012 Management shell:

Open the Microsoft dynamics AX2012 Management shell from Adminitrative tools.
At the command prompt, type the following command, and then press ENTER.
axutil import /file:<filename> 
This command installs the specified file in the same layer that it was exported from.

If the installation fails because of a conflict and still you want to import the model to resolve conflicts,you can rerun the command, and use the /conflict:push option to push the element that has the conflict to the related update layer. You can then resolve the conflict. 
axutil import /conflict:push /file:<filename> 

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;