Hi,
I found a beautiful thing while searching for AX dev. from http://discoverax.blogspot.com/2007/12/color-code-your-dynamics-environments.html
following code explain that how to set form's color company wise.
public void run()
{
;
super();
// Set the color scheme of this instance of te SysFormRUn to RGB
this.design().colorScheme(FormColorScheme::RGB);
// Switch and based on the current company change colors, or not for default
switch (curext())
{
case 'DEM':
this.design().backgroundColor(WinAPI::navisionColorRed());
break;
case 'dat':
this.design().backgroundColor(WinAPI::navisionColorBeige());
break;
default:
break;
}
}
Some points:
1. Here curext() will return the current extension for the current company.
2. To get current company name, SRSVSToolsSupport::getFullCompanyName(curext())
3. You can also use appl.company.ext() to get the current extension but will makes a call to server tier which is not effective in some cases.
Thanks,
Ashlesh
Thursday, August 19, 2010
Monday, August 16, 2010
How to declare and initialize a Global Object
If you wanted to declare your own global variable object throughout AX application development, below code might be helpful to you.
[your COM DLL Class Name] = WMInterface (this is for my reference)
[your COM DLL Class Init()] = Init() (this is for my reference)
WMInterface WMI;
SysGlobalCache gch = appl.globalCache();
;
WMI = new WMInterface()
WMI.Init();
gch.set(classstr(WMInterface), "WMKey", WMI);
In above line "WMKey" is the unique key to store the unique entry for (Key, Value) pair and WMI is the value for this unique entry.
Thats all.
Now when you want to reuse this object declare, follow steps:
[your desired COM DLL Class method name] = OpenNewItem(int value) (this is for my reference)
WMInterface wmi;
SysGlobalCache gc = appl.globalCache();
;
wmi = gc.get(classstr(WMInterface),"WMKey",null);
wmi.OpenNewItem(1);
Hope it helps someone.
Thanks,
Ashlesh
[your COM DLL Class Name] = WMInterface (this is for my reference)
[your COM DLL Class Init()] = Init() (this is for my reference)
WMInterface WMI;
SysGlobalCache gch = appl.globalCache();
;
WMI = new WMInterface()
WMI.Init();
gch.set(classstr(WMInterface), "WMKey", WMI);
In above line "WMKey" is the unique key to store the unique entry for (Key, Value) pair and WMI is the value for this unique entry.
Thats all.
Now when you want to reuse this object declare, follow steps:
[your desired COM DLL Class method name] = OpenNewItem(int value) (this is for my reference)
WMInterface wmi;
SysGlobalCache gc = appl.globalCache();
;
wmi = gc.get(classstr(WMInterface),"WMKey",null);
wmi.OpenNewItem(1);
Hope it helps someone.
Thanks,
Ashlesh
Tuesday, August 10, 2010
Use Axapta CCADO classes to interact with other databases
Hi,
As per my point of view to access the database outside of AX DB using the CCADO classes method is more effective than using the LoginProperty class.
Below is the use of CCADO classes:
Basically there are 3 main classes:
1. CCADOConnection
2. CCADORecordSet
3. CCADOCommand
Below is the source code template to use the CCADO classes in AX:
X++:
static void Tutorial_CCADO (Args _args)
{
CCADOConnection Connection; CCADOConnection Connection;
SQL str;
CCADORecordSet RSet;
CCADOCommand ADOCom;
;
CCADOConnection = new Connection ();
Connection. ConnectionString (StrFmt ("Provider = SQLOLEDB.1; Persist Security Info = False; User ID =% 3;Password =% 4; Initial Catalog =% 2; Data Source =% 1, '192 .162.0.100','TestBBDD','Sa','sa'));
//Open the connection
Connection.Open ();
CCADORecordSet Rset = new ();
// The decision to execute
SQL = 'Select * from CustTable';
// Execute the query using the previously opened connection
RSET.Open(SQL, Connection);
// Loop while there are records
While(!RSET.EOF())
(
// Display the field AccountNum
info(RSet.fields().itemName('Accountnum').value());
// Next Record
RSet.moveNext();
)
// Now ADOCommand
ADOCom = new CCADOCommand();
// Open connection I associate
ADOCom.activeConnection(Connection);
// Prepare a SQL data modification
SQL = "delete CustTable where AccountNum = '%1'";
// Execute the sentence - in theory delete the record 'cli0001'
ADOCom.commandText(StrFmt( SQL, 'cli0001'));
ADOCom.Execute();
}
Thanks,
Ashlesh
As per my point of view to access the database outside of AX DB using the CCADO classes method is more effective than using the LoginProperty class.
Below is the use of CCADO classes:
Basically there are 3 main classes:
1. CCADOConnection
2. CCADORecordSet
3. CCADOCommand
Below is the source code template to use the CCADO classes in AX:
X++:
static void Tutorial_CCADO (Args _args)
{
CCADOConnection Connection; CCADOConnection Connection;
SQL str;
CCADORecordSet RSet;
CCADOCommand ADOCom;
;
CCADOConnection = new Connection ();
Connection. ConnectionString (StrFmt ("Provider = SQLOLEDB.1; Persist Security Info = False; User ID =% 3;Password =% 4; Initial Catalog =% 2; Data Source =% 1, '192 .162.0.100','TestBBDD','Sa','sa'));
//Open the connection
Connection.Open ();
CCADORecordSet Rset = new ();
// The decision to execute
SQL = 'Select * from CustTable';
// Execute the query using the previously opened connection
RSET.Open(SQL, Connection);
// Loop while there are records
While(!RSET.EOF())
(
// Display the field AccountNum
info(RSet.fields().itemName('Accountnum').value());
// Next Record
RSet.moveNext();
)
// Now ADOCommand
ADOCom = new CCADOCommand();
// Open connection I associate
ADOCom.activeConnection(Connection);
// Prepare a SQL data modification
SQL = "delete CustTable where AccountNum = '%1'";
// Execute the sentence - in theory delete the record 'cli0001'
ADOCom.commandText(StrFmt( SQL, 'cli0001'));
ADOCom.Execute();
}
Thanks,
Ashlesh
Subscribe to:
Posts (Atom)