Monday, April 26, 2010

Open any object from code editor to in AOT node(Editor script)


I have posted a editor script method earlier that can open and browse table for code editor.using below code developer will have ease of opening any object from AX code editor to AOT node

TO USE THIS CODE COPY AND PASTE THE METHOD IN EDITOR SCRIPT CLASS

void AX_OpenInAOT(Editor e)
{
#AOT
TreeNode treeNode;
FreeText selectedLine;
str 1 curSymbol;
int iCopyFrom;
int iCopyTo;
Set selectedNodesSet = new Set(Types::Class);
SetIterator setIterator;
Map map;

void add2Set(TreeNodePath _path)
{
;
treeNode = TreeNode::findNode(_path + #AOTRootPath + selectedLine);
if (treeNode)
selectedNodesSet.add(treeNode);
}
;
if (e.markMode() != MarkMode::NoMark && e.selectionStartCol() != e.selectionEndCol())
{
selectedLine = strLRTrim(subStr(e.currentLine(), e.selectionStartCol(), e.selectionEndCol() - e.selectionStartCol()));
}
else
{
selectedLine = e.currentLine();
for (iCopyFrom = e.columnNo()+1; iCopyFrom >= 0; iCopyFrom--)
{
curSymbol = subStr(selectedLine, iCopyFrom, 1);
if (!strAlpha(curSymbol))
break;
}
for (iCopyTo = e.columnNo()+1; iCopyTo <= strLen(selectedLine); iCopyTo++) { curSymbol = subStr(selectedLine, iCopyTo, 1); if (!strAlpha(curSymbol)) break; } selectedLine = (iCopyFrom <> 0)
{
setIterator = new SetIterator(selectedNodesSet);
setIterator.begin();
if (selectedNodesSet.elements() == 1)
{
treeNode = setIterator.value();
}
else
{
map = new Map(Types::String, Types::String);
while (setIterator.more ())
{
treeNode = setIterator.value();
map.insert(treeNode.treeNodePath(), treeNode.AOTparent().treeNodeName());
setIterator.next();
}
treeNode = TreeNode::findNode(pickList(map, "Location", "Select element type"));
}
if (treeNode && treeNode.treeNodePath() != TreeNode::rootNode().treeNodePath())
{
if (SysTreeNode::hasSource(treeNode))
{
if (treeNode.AOTparent().treeNodePath() == #macrosPath && subStr(e.currentLine(), e.selectionStartCol () - 1, 1) != '#')
return;
treeNode.AOTedit();
}
else
{
treeNode.AOTnewWindow();
}
}
}
}
}

String function class

While working on string function i have found an nice code on Greg Pierce's blog extending existing AX string function functionality to construct newer method above post is in AX 3.0 and 4.0 below code is in AX 2009

COPY PASTE THE CODE IN NOTE PAD AND SAVE AS XPO.

Exportfile for AOT version 1.0 or later
Formatversion: 1

***Element: CLS

; Microsoft Dynamics AX Class: String_Func unloaded
; --------------------------------------------------------------------------------
CLSVERSION 1

CLASS #String_Func
Id 30211
PROPERTIES
Name #String_Func
Extends #
RunOn #Called from
ENDPROPERTIES

METHODS
Version: 3
SOURCE #trimToLength
#/* trim a string to a length, optionally add ellipsis if string is truncated.*/
#public static str trimToLength( str _s, int _length, str _trimStr = "" )
#{
# str s;
#
# if( strlen( _s ) < s =" strdel(" exceptions =" [" fl =" true;" s =" strltrim(" ix =" 1;" s1 =" strdel(" s1 =" strdel(" fl =" true;" s =" strpoke(" s =" strpoke(" fl =" false;" pos =" strscan(" fname =" strdel(" lastname =" strdel(" s =" _s," pos =" 1," loc =" strscan(" loc ="=" c =" conins("> 0 )
# {
# _value = strdel( s, loc, strlen(s) - loc + 1 );
#
# if( _value && _value != _delimeter )
# {
# c = conins( c, pos, _value );
# pos++;
# }
# s = strdel( s, 1, loc );
#
# loc = strscan( s, _delimeter, 1, strlen( s ) );
# }
# if( s && s != _delimeter )
# c = conins( c, pos, s );
#
# return c;
#
#}
ENDSOURCE
SOURCE #rSplit
#/* split item of right of string, trimmed at delimiter*/
#static str rSplit( str _s, str _delimeter )
#
#{
# str s = "";
# int pos;
# int len = strlen( _s );
#
# pos = strfind( _s, _delimeter, len, -len );
# s = strdel( _s, 0, pos );
#
#
# return s;
#}
ENDSOURCE
SOURCE #replaceAll
#/* replace the all occurances of "findStr" with "replStr" in "s"*/
#
# static str replaceAll( str s, str findStr, str replStr )
# {
# int pos = strscan( s, findStr, 1, strlen( s ) );
#
# while( pos > 0 )
#
# {
# s = strdel( s, pos, strlen( findStr ) );
# s = strins( s, replStr, pos );
#
# pos = strscan( s, findStr, pos + strlen( replStr ), strlen( s ) );
#
# }
#
# return s;
# }
ENDSOURCE
SOURCE #replace
#/* replace the first occurance of "findStr" with "replStr" in "s"*/
#
#static str replace( str s, str findStr, str replStr )
#
#{
# int pos = strscan( s, findStr, 1, strlen( s ) );
#
# if( pos > 0 )
# {
# s = strdel( s, pos, strlen( findStr ) );
# s = strins( s, replStr, pos );
#
# }
#
# return s;
#}
ENDSOURCE
SOURCE #randomString
#/* build a random string of length passed*/
#public static str randomString( int _length = 6 )
#{
# str s;
# int ix = 0;
# str nxt;
# RandomGenerate random = new RandomGenerate();
# ;
#
# for( ix = 0; ix < nxt =" int2str(" random =" new" s = ""> " + ( String_Func::beginsWith( "abcdef", "abc" ) ? "true" : "false" ) );
#
#
# info( "String_Func::endsWith( \"abcdef\", \"def\" ) -> " + ( String_Func::endsWith( "abcdef", "def" ) ? "true" : "false" ) );
#
#
# info( "String_Func::fillString( 10, \"a\" ) -> " + String_Func::fillString( 10, "a" ) );
#
# info( "String_Func::replace( \"abc123abc123\", \"abc\", \"def\" ) -> " + String_Func::replace( "abc123abc123", "abc", "def" ) );
#
#
# info( "String_Func::replaceAll( \"abc123abc123\", \"abc\", \"def\" ) -> " + String_Func::replaceAll( "abc123abc123", "abc", "def" ) );
#
#
# info( "String_Func::randomString( 8 ) -> " + String_Func::randomString() );
#
# info( "String_Func::rSplit( \"abc|def\", \"|\" ) -> " + String_Func::rSplit( "abc|def", "|" ) );
#
#
#}
ENDSOURCE
SOURCE #fillString
#/* build a repeating string of length ct
# */
#
#public static str fillString( int ct, str char = " " )
#
#{
# int ix;
# str s = "";
# ;
#
# for( ix = 0; ix < trim =" strdel(" trim ="="> 0 )
# return true;
#
# return false;
#
# }
ENDSOURCE
SOURCE #cleanString
#/* use to do multiple string manipulations on the string passed, including case forcing and substitutions */
#
# static str cleanString( str s, container forceLower, container forceUpper, container subst, boolean flFixDoubleSpaces = true )
# {
# int ix;
#
#
# // FIX LOWER CASE LIST
# for( ix = 1; ix <= conlen( forceLower ); ix++ )
# {
# s = String_Func::replaceAll( s, conpeek( forceLower, ix ), strlwr( conpeek( forceLower, ix ) ) );
#
# }
#
# // FIX UPPER CASE LIST
# for( ix = 1; ix <= conlen( forceUpper ); ix++ )
# {
# s = String_Func::replaceAll( s, conpeek( forceUpper, ix ), strupr( conpeek( forceUpper, ix ) ) );
#
# }
#
# // DO SUBSTITUTIONS
# for( ix = 1; ix <= conlen( subst ); ix++ )
# {
# s = String_Func::replaceAll( s, conpeek( conpeek( subst, ix ), 1 ), conpeek( conpeek( subst, ix ), 2 ) );
#
# }
#
# // FIX double spaces
# if( flFixDoubleSpaces )
# {
# while( String_Func::contains( s, " " ) )
# {
# s = String_Func::replaceAll( s, " ", " " );
#
# }
# }
#
# return s;
#
# }
ENDSOURCE
SOURCE #beginsWith
#/*return true if "findStr" is the inital character match for "s" */
#
# static boolean beginsWith( str s, str findStr )
#
# {
# if( strscan( s, findStr, 1, strlen( s ) ) == 1 )
# return true;
#
# return false;
# }
ENDSOURCE
SOURCE #classDeclaration
#public class String_Func
#{
#}
ENDSOURCE
ENDMETHODS
ENDCLASS

***Element: END

Tuesday, February 23, 2010

Create formated Excel reports from Ax 2009

Extracting Excel reports from Dynamics AX 2009 is easier task but client ask for formatted reports developers face a problem in generating a report directly in excel as per client requirement as:
1. Borders
2. interiors
3. Bold/Italicheader
4. image in excel
5. Fonts
6. Underline










Below class can be used to generate the reports copy the code in text file and save in xpo import the file in Dynamcis AX 2009

Exportfile for AOT version 1.0 or later
Formatversion: 1

***Element: CLS

; Microsoft Dynamics AX Class: ExcelReporter unloaded
; --------------------------------------------------------------------------------
CLSVERSION 1

CLASS #ExcelReporter
Id 30095
PROPERTIES
Name #ExcelReporter
Extends #
RunOn #Called from
ENDPROPERTIES

METHODS
Version: 3
SOURCE #classDeclaration
#class ExcelReporter
#{
# COM excelApplication;
# COM excelWorkBooks;
# COM excelWorkBook;
# COM excelWorkSheets;
# COM excelWorkSheet;
# COM excelCell;
# COM Module;
# COM range;
# COM Borders;
# COM Border;
# COM font;
# COM styles;
# COM style;
# COM interior;
# COM entireColumn;
# COM formula;
#
# COM AutoFilter;
# COM EnableAutoFilter ;
#
# COM excelCharts;
# COM excelChart;
#
# COM ActiveChart;
# COM ChartObjects;
# COM WrapText;
# COM ColoumnWidth;
#
#
# int lineNum;
#
# Array arr;
#
# str sCode;
# int ColNameLen;
#
#
#}
ENDSOURCE
SOURCE #ColoumnWidth
#void ColoumnWidth(COM _range,int Value)
#{
# ColoumnWidth = _range.ColoumnWidth(value);
#}
ENDSOURCE
SOURCE #companyLogo
#display Bitmap companyLogo()
#{
# CompanyInfo companyInfo = CompanyInfo::find();
# ;
#
# return CompanyImage::find(companyInfo.DataAreaId, companyInfo.TableId, companyInfo.RecId).Image;
#}
ENDSOURCE
SOURCE #getColChar
#str getColChar(int _num)
#{
# int basePosition = 0;
# int Counts;
# str char;
# int expo;
# boolean flagfound;
#
#
# if(_num > 16384)
# throw error('Not Supported by the system');
#
# ColNameLen = 1;
# while(_num > power(26,ColNameLen))
# {
# ColNameLen = ColNameLen + 1;
# }
#
#
# while(!flagfound)
# {
# switch(_num)
# {
# case 1+basePosition :
# char = 'A';
# break;
#
# case 2+basePosition :
# char = 'B';
# break;
#
# case 3+basePosition :
# char = 'C';
# break;
#
# case 4+basePosition :
# char = 'D';
# break;
#
# case 5+basePosition :
# char = 'E';
# break;
#
# case 6+basePosition :
# char = 'F';
# break;
#
# case 7+basePosition :
# char = 'G';
# break;
#
# case 8+basePosition :
# char = 'H';
# break;
#
# case 9+basePosition :
# char = 'I';
# break;
#
# case 10+basePosition :
# char = 'J';
# break;
#
# case 11+basePosition :
# char = 'K';
# break;
#
# case 12+basePosition :
# char = 'L';
# break;
#
# case 13+basePosition :
# char = 'M';
# break;
#
# case 14+basePosition :
# char = 'N';
# break;
#
# case 15+basePosition :
# char = 'O';
# break;
#
# case 16+basePosition :
# char = 'P';
# break;
#
# case 17+basePosition :
# char = 'Q';
# break;
#
# case 18+basePosition :
# char = 'R';
# break;
#
# case 19+basePosition :
# char = 'S';
# break;
#
# case 20+basePosition :
# char = 'T';
# break;
#
# case 21+basePosition :
# char = 'U';
# break;
#
# case 22+basePosition :
# char = 'V';
# break;
#
# case 23+basePosition :
# char = 'W';
# break;
#
# case 24+basePosition :
# char = 'X';
# break;
#
# case 25+basePosition :
# char = 'Y';
# break;
#
# case 26+basePosition :
# char = 'Z';
# break;
# }
# if(char)
# flagfound = true;
#
# if(basePosition)
# counts = counts + 1;
#
# basePosition = basePosition + 26;
# }
#
#
# if(strlen(char) < ColNameLen)
# char = this.getColChar(counts) + char;
#
# return char;
#
#}
#
#
#
#
#
#
#
#
#
#
#/* switch(_num)
# {
# case 1 :
# return 'A';
# break;
#
# case 2 :
# return 'B';
# break;
#
# case 3 :
# return 'C';
# break;
#
# case 4 :
# return 'D';
# break;
#
# case 5 :
# return 'E';
# break;
#
# case 6 :
# return 'F';
# break;
#
# case 7 :
# return 'G';
# break;
#
# case 8 :
# return 'H';
# break;
#
# case 9 :
# return 'I';
# break;
#
# case 10 :
# return 'J';
# break;
#
# case 11 :
# return 'K';
# break;
#
# case 12 :
# return 'L';
# break;
#
# case 13 :
# return 'M';
# break;
#
# case 14 :
# return 'N';
# break;
#
# case 15 :
# return 'O';
# break;
#
# case 16 :
# return 'P';
# break;
#
# case 17 :
# return 'Q';
# break;
#
# case 18 :
# return 'R';
# break;
#
# case 19 :
# return 'S';
# break;
#
# case 20 :
# return 'T';
# break;
#
# case 21 :
# return 'U';
# break;
#
# case 22 :
# return 'V';
# break;
#
# case 23 :
# return 'W';
# break;
#
# case 24 :
# return 'X';
# break;
#
# case 25 :
# return 'Y';
# break;
#
# case 26 :
# return 'Z';
# break;
#
#
#
#
#
# }
#
#}
#*/
#
ENDSOURCE
SOURCE #insertHeader
#void insertHeader(Types _types,
# int _idx,
# str _xlRowCol,
# str _value)
#{
# arr = new Array(_types);
# arr.value(_idx,_value);
# range = excelWorkSheet.Range(_xlRowCol);
# range.value2(COMVariant::createFromArray(arr));
#}
#
#
#
#
ENDSOURCE
SOURCE #insertImage
#void insertImage(int _idx,
# str _xlRowCol,
# Bitmap _value)
#{
# ;
# range = excelWorkSheet.Range(_xlRowCol);
# range.value(_value);
#}
#
#
#
#
ENDSOURCE
SOURCE #new
#void new()
#{
# ;
# excelApplication = new COM("excel.application");
# excelWorkBooks = excelApplication.workBooks();
# excelWorkBook = excelWorkBooks.add();
# excelWorkSheets = excelWorkBook.worksheets();
# excelWorkSheet = excelWorkSheets.add();
#
#}
ENDSOURCE
SOURCE #variant2COM
#void variant2COM(COM _COM, COMVariant _variant)
#
# {
#
# _COM.attach(_variant.iDispatch());
#
# }
#
ENDSOURCE
SOURCE #xlAllBorder
#void xlAllBorder(COM _range,int _weight)
#{
# Borders = _range.Borders();
# Border = Borders.Item(2);
# Border.lineStyle(7);
# Border.Weight(_weight);
#
# Borders = null;
# border = null;
#
# Borders = _range.Borders();
# Border = Borders.Item(1);
# Border.lineStyle(7);
# Border.Weight(_weight);
#
# Borders = null;
# border = null;
#
# Borders = _range.Borders();
# Border = Borders.Item(8);
# Border.lineStyle(7);
# Border.Weight(_weight);
#
# Borders = null;
# border = null;
#
# Borders = _range.Borders();
# Border = Borders.Item(9);
# Border.lineStyle(7);
# Border.Weight(_weight);
#
#}
ENDSOURCE
SOURCE #xlAutoFilter
#void xlAutoFilter(str _xlRowCol,
# boolean _Filter)
#
#
#
#{
# ;
# range = excelWorkSheet.Range(_xlRowCol);
#
#}
ENDSOURCE
SOURCE #xlAutoFit
#void xlAutoFit(COM _range)
#{
# entireColumn = _range.entireColumn();
# entirecolumn.autofit();
#}
ENDSOURCE
SOURCE #xlBotBorder
#void xlBotBorder(COM _range)
#{
# Borders = _range.Borders();
# Border = Borders.Item(9);
# Border.lineStyle(7);
# Border.Weight(3);
#}
ENDSOURCE
SOURCE #xlBoxBorder
#void xlBoxBorder(str _row,str _coll,int _weight)
#{
# int rowNum = any2int(strdel(_row,1,1));
# int collNum = any2int(strdel(_coll,1,1));
# str row = strdel(_row,2,strlen(_row));
# str coll = strdel(_coll,2,strlen(_coll));
#
# Com _range;
# // top
# _range = excelWorkSheet.Range(strfmt("%1%2",row,rownum),strfmt("%1%2",coll,rownum));
#
# Borders = _range.Borders();
# Border = Borders.Item(8);
# Border.lineStyle(7);
# Border.Weight(_weight);
#
# Borders = null;
# border = null;
# _range = null;
#
# // left
# _range = excelWorkSheet.Range(strfmt("%1%2",row,rownum),strfmt("%1%2",row,collnum));
#
# Borders = _range.Borders();
# Border = Borders.Item(1);
# Border.lineStyle(7);
# Border.Weight(_weight);
#
# Borders = null;
# border = null;
# _range = null;
#
# // right
# _range = excelWorkSheet.Range(strfmt("%1%2",num2char(char2num(coll,1)+1),rownum),strfmt("%1%2",num2char(char2num(coll,1)+1),collnum));
#
# Borders = _range.Borders();
# Border = Borders.Item(1);
# Border.lineStyle(7);
# Border.Weight(_weight);
#
# Borders = null;
# border = null;
# _range = null;
#
# // bottom
# _range = excelWorkSheet.Range(strfmt("%1%2",row,collnum+1),strfmt("%1%2",coll,collnum+1));
#
# Borders = _range.Borders();
# Border = Borders.Item(8);
# Border.lineStyle(7);
# Border.Weight(_weight);
#
# Borders = null;
# border = null;
# _range = null;
#}
#
ENDSOURCE
SOURCE #xlChart
#void xlChart(str _xlRowCol,
# str _Text)
#
#
#{
#
#}
ENDSOURCE
SOURCE #xlClose
#void xlClose()
#{
# excelApplication.quit();
#}
ENDSOURCE
SOURCE #xlCreateHeader
#Array xlCreateHeader(Array _arr,
# int _idx,
# str _value)
#{
# _arr.value(_idx,_value);
# return _arr;
#}
#
#
#
#
ENDSOURCE
SOURCE #xlFormatCell
#void xlFormatCell(str _xlRowCol,
# int _fontSize,
# boolean _bold,
# boolean _italic,
# boolean _strikethrough,
# int _underline,
# boolean _Subscript,
# boolean _Superscript,
# str _fontname)
#
#
#
#
#{
# ;
# range = excelWorkSheet.Range(_xlRowCol);
# font = range.Font();
# font.Size(_fontSize);
# font.bold(_bold);
# font.italic(_italic);
# font.underline(_underline);
# font.strikethrough(_strikethrough);
# font.Subscript(_Subscript);
# font.Superscript(_Superscript);
# font.name(_fontname);
#
#}
#
ENDSOURCE
SOURCE #xlFormula
#void xlFormula(str _xlRowCol)
#{
# ;
# range = excelWorkSheet.Range(_xlRowCol);
#
# formula = range.formula();
#}
#
ENDSOURCE
SOURCE #xlFormulan
#COM xlFormulan()
#{
# ;
# formula = range.formula();
# return formula;
#}
#
ENDSOURCE
SOURCE #xlGridBorder
#void xlGridBorder(COM _range,int _weight)
#{
# Borders = _range.Borders();
# Border = Borders.Item(2);
# Border.lineStyle(7);
# Border.Weight(_weight);
#
# Borders = null;
# border = null;
#
# Borders = _range.Borders();
# Border = Borders.Item(1);
# Border.lineStyle(7);
# Border.Weight(_weight);
#
# Borders = null;
# border = null;
#
# Borders = _range.Borders();
# Border = Borders.Item(8);
# Border.lineStyle(7);
# Border.Weight(_weight);
#
# Borders = null;
# border = null;
#
# Borders = _range.Borders();
# Border = Borders.Item(9);
# Border.lineStyle(7);
# Border.Weight(_weight);
#
# Borders = null;
# border = null;
#
# Borders = _range.Borders();
# Border = Borders.Item(3);
# Border.lineStyle(7);
# Border.Weight(_weight);
#
#}
ENDSOURCE
SOURCE #xlHorizontaltBorder
#void xlHorizontaltBorder(str _row,str _coll,int _weight)
#{
# int rowNum = any2int(strdel(_row,1,1));
# int collNum = any2int(strdel(_coll,1,1));
# str row = strdel(_row,2,strlen(_row));
# str coll = strdel(_coll,2,strlen(_coll));
#
# Com _range;
# // top
# _range = excelWorkSheet.Range(strfmt("%1%2",row,rownum),strfmt("%1%2",coll,rownum));
#
# Borders = _range.Borders();
# Border = Borders.Item(8);
# Border.lineStyle(7);
# Border.Weight(_weight);
#
# Borders = null;
# border = null;
# _range = null;
#
# // left
# _range = excelWorkSheet.Range(strfmt("%1%2",row,rownum),strfmt("%1%2",row,collnum));
#
# Borders = _range.Borders();
# Border = Borders.Item(1);
# Border.lineStyle(7);
# Border.Weight(_weight);
#
# Borders = null;
# border = null;
# _range = null;
#
# // right
# _range = excelWorkSheet.Range(strfmt("%1%2",num2char(char2num(coll,1)+1),rownum),strfmt("%1%2",num2char(char2num(coll,1)+1),collnum));
#
# Borders = _range.Borders();
# Border = Borders.Item(1);
# Border.lineStyle(7);
# Border.Weight(_weight);
#
# Borders = null;
# border = null;
# _range = null;
#
# // bottom
# _range = excelWorkSheet.Range(strfmt("%1%2",row,collnum+1),strfmt("%1%2",coll,collnum+1));
#
# Borders = _range.Borders();
# Border = Borders.Item(8);
# Border.lineStyle(7);
# Border.Weight(_weight);
#
# Borders = null;
# border = null;
# _range = null;
#
# _range = excelWorkSheet.Range(strfmt("%1%2",row,rownum),strfmt("%1%2",coll,collnum));
# Borders = _range.Borders();
# Border = Borders.Item(8);
# Border.lineStyle(7);
# Border.Weight(_weight);
#
# Borders = null;
# border = null;
#
# _range = excelWorkSheet.Range(strfmt("%1%2",row,rownum),strfmt("%1%2",coll,collnum));
# Borders = _range.Borders();
# Border = Borders.Item(9);
# Border.lineStyle(7);
# Border.Weight(_weight);
#
# Borders = null;
# border = null;
#
# _range = excelWorkSheet.Range(strfmt("%1%2",row,rownum),strfmt("%1%2",coll,collnum));
# Borders = _range.Borders();
# Border = Borders.Item(3);
# Border.lineStyle(7);
# Border.Weight(_weight);
#
#}
ENDSOURCE
SOURCE #xlInsert
#void xlInsert(Types _types,
# int _row,
# int _col,
# str _value)
#{
# excelcell = excelworksheet.cells();
# this.variant2COM(excelcell, excelcell.item(_row,_col));
# excelcell.value2(_value);
#}
#
#
#
#
ENDSOURCE
SOURCE #xlInsertArr
#void xlInsertArr(Array _arr,
# str _xlRowCol)
#{
# ;
# range = excelWorkSheet.Range(_xlRowCol);
# range.value2(COMVariant::createFromArray(_arr));
#}
ENDSOURCE
SOURCE #xlInsertss
#void xlInsertss(Types _types,
# int _row,
# int _col,
# str _value)
#{
# str xlcol = this.getColChar(_col);;
# arr = new Array(_types);
# arr.value(1,_value);
# range = excelWorkSheet.Range(strfmt("%1%2",xlcol,_row));
# range.value2(COMVariant::createFromArray(arr));
#}
#
#
#
#
ENDSOURCE
SOURCE #xlInsertTblArr
#Array xlInsertTblArr(Common _common,
# int _refFieldId,
# Array _arr,
# int _idx)
#{
# dictIndex dictIndex ;
# ;
#
# dictIndex = new DictIndex(_common.tableId,_refFieldId);
# _arr.value(_idx,_common.(dictIndex.field(_refFieldId)));
#
# return _arr;
#}
ENDSOURCE
SOURCE #xlInterior
#void xlInterior(str _xlRowCol,
# int _Index)
#{
#
# ;
# range = excelWorkSheet.Range(_xlRowCol);
# interior = range.interior();
#
# interior.colorIndex(_Index);
#
#}
ENDSOURCE
SOURCE #xlLeftBorder
#void xlLeftBorder(COM _range)
#{
# Borders = _range.Borders();
# Border = Borders.Item(2);
# Border.lineStyle(7);
# Border.Weight(3);
#}
ENDSOURCE
SOURCE #xlRange
#com xlRange(str _row, str _col)
#{
# ;
# range = excelWorkSheet.Range(_row,_col);
# return range;
#}
ENDSOURCE
SOURCE #xlrightBorder
#void xlrightBorder(COM _range)
#{
# Borders = _range.Borders();
# Border = Borders.Item(1);
# Border.lineStyle(7);
# Border.Weight(3);
#}
ENDSOURCE
SOURCE #xlShow
#void xlShow()
#{
# excelApplication.visible(true);
#}
ENDSOURCE
SOURCE #xlStyle
#void xlStyle(Com _range,Int _color,str _styleName)
#{
# styles = null;
# style = null;
# interior = null;
# styles = excelWorkBook.styles();
# style = styles.add(_styleName);
# interior = style.interior();
# interior.color(_color);//WinApi::RGB2int(246, 233, 206));
# _range.style(_styleName);
#}
ENDSOURCE
SOURCE #xlTopBorder
#void xlTopBorder(COM _range)
#{
# Borders = _range.Borders();
# Border = Borders.Item(8);
# Border.lineStyle(7);
# Border.Weight(3);
#}
ENDSOURCE
SOURCE #xlWorkSheetName
#void xlWorkSheetName(str _name)
#{
# excelWorkSheet.name(_name);
#}
ENDSOURCE
SOURCE #xlWrap
#void xlWrap(COM _range)
#{
# wrapText = _range.wraptext(true);
#}
ENDSOURCE
ENDMETHODS
ENDCLASS

***Element: END

X++ Code to restrict user login multiple times in ax2009

Copy Paste the Following Code in startupPost method of info class in AOT

void startupPost()
{
// To restrict user login form second login
xSession session;
SysClientSessions SysClientSessions;
UserId currentUserId;
int counter;

;

currentUserId = curUserId();

if(currentUserId!="Admin")// Allow Admin User to login multiple time
{
while select SysClientSessions
where SysClientSessions.userId == currentUserId &&
SysClientSessions.Status == 1 // 1 : Login 0 : Logout
{
session = new xSession(SysClientSessions.SessionId, true);
if (session && session.userId())
{
counter++;
}
}

if(counter>=2)
{
Box::stop("Already Logged-in : The same user id can't log in twice.");
infolog.shutDown(true);
}
}
}


Please take backup of your application before copying code

Monday, December 1, 2008

Microsoft Dynamics AX 2009 Application Integration Framework(AIF) Benchmark

Microsoft Dynamics AX 2009 Application Integration Framework Benchmark

Microsoft Dynamics AX Application Integration Framework Benchmark exercises Core Sales Order processing thru Invoicing and GL Creation thru posting with high degree of scale

In June 2008, Microsoft Corporation conducted the Microsoft Dynamics® AX 2009 Application Integration Framework (AIF) benchmark to measure the performance and scalability characteristics of Microsoft Dynamics® AX 2009 in a simulated distribution scenario. This benchmark exercised core Accounts Receivables scenario involving sales order creation thru AIF and invoicing of sales orders thru batch jobs. It also exercised core General Ledger scenario involving journal creation thru AIF and posting of journals thru batch jobs. The scenarios generated load on Application Object Server (AOS)—in this benchmark, each AOS instance was hosted on a separate server. In a Microsoft Dynamics® AX system, the AOS processes business logic in communication with clients and the database; the database server provides data to the AOS.

For more information and download please check the following link AX 2009 Application Integration Framework Benchmark

Microsoft Dynamics Snap sample applications for Microsoft Dynamics AX 2009

Release of Microsoft Dynamics Snap sample applications for use with Microsoft Dynamics AX 2009

These samples show the potential of integrating the 2007 Microsoft® Office system with Microsoft Dynamics® AX by providing functioning end-to-end capabilities in source code form. Partners and customers can build on these samples and use the techniques they employ to build solutions that access the data and processes in Microsoft Dynamics AX from the productivity and collaboration tools of the Microsoft Office system. Two snap applications are now available with Microsoft Dynamics AX 2009:

This release contains the following snap-in applications for use with Microsoft Dynamics AX 2009 and Microsoft Office 2007.

Offline Expense - This snap-in enables expenses to be entered in Excel while disconnected from the corporate network, and then posted to Dynamics AX at a later time. This snap-in uses WCF-based services and LINQ to retrieve data from Dynamics AX, and uses the Application Integration Framework, or AIF to send business documents to Dynamics AX.

Business Data Lookup (BDL) - This snap-in enables information workers to access data from Dynamics AX from within Excel, Word and Outlook. This snap-in is an upgrade of the BDL snap-in that was distributed with Microsoft Dynamics AX 4.0.

These applications require .Net 3.5, Microsoft Office 2007, Microsoft Visual Studio 2008 and Microsoft Dynamics AX 2009. Each snap-in contains a document describing the basic architecture, functional footprint, and deployment steps for exploring the sample code.

For more information and download please check the following link Microsoft Dynamics Snap for Dynamics AX 2009

Microsoft Dynamics AX 2009 Service Pack 1

During EMEA Convergence, the release of Microsoft Dynamics AX 2009 SP1 was announced. You can see the announcement of SP1 availability on the Microsoft Dynamics AX Landing Page on PartnerSource.

Similarly, you can see the announcement on the Microsoft Dynamics AX Landing Page on CustomerSource.

With the download of Microsoft Dynamics AX 2009 SP1 the following materials will be made available:

– Service Pack 1 Downloadable Package

– Downloadable Package for Updated Help Files*

– Release Notes (List of known issues)

– Updated What’s New Document – A section on SP1 is added

- Service Pack 1 Install Guide

For further details on SP1 please take the links to PartnerSource and CustomerSource announcements.