Monday, September 6, 2010

Enable User ID from SQL in AX 2009

Enabling user Id in Axapta 3.0 from SQL was easy you need to update enable field to 1 only this but in AX 2009 if coincidently you have disable userID having Administrator access then updating enable filed will not work few days back coincidently i had done the same :) disabled my ID now being only user having administrator privledge i got stuck.

Now to enable it from back end SQL you need to update enable flag to 1 and provide SID in UserInfo table to get SID you can user following job as provided in Screenshot in some other application in  but in same domain



then use following query in SQL 

select * from USERINFO where  ID = 'secu'

update USERINFO set ENABLE = 1 where ID = 'secu'

update USERINFO set SID = 'S-1-5-21-2656439898-1577874530-2966910584-8962' where ID = 'secu' 

all this to enable from SQL ...........
Cheerz.......

Friday, May 14, 2010

Microsoft Dynamics Convergence 2010 Web Seminar Series

Take time to review these highly rated web seminars from the Convergence Virtual Partner Briefing. They will give you important updates on upgrades & renewals, how to compete effectively against NetSuite, Partner Development Centers, new MPN requirements and Partner Business Systems.

Microsoft Dynamics Convergence 2010 Web Seminar Series

*Require partner source login

Tuesday, May 11, 2010

Sure Step 2010 Now Available

Microsoft Dynamics Sure Step 2010 is available for download now it provides a complete methodology—including project management discipline and field-tested best practices—plus user-friendly tools that enable you to more successfully deploy, migrate, configure, and upgrade.
Download and Install Sure Step* – NEW Sure Step 2010!
For more information on installing and using Sure Step, read the Sure Step User Guide.*

*Requires Partner source access

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