Tuesday, September 18, 2007
How to Run Time Add Code to AOT
refFieldId)
{
#AOT
TreeNode treeNode;
TreeNode methodsTreeNode;
str oldsource;
str newsource;
str superString = "super()";
str busRuleString;
str newMethodName;
str newMethodCode;
;
treeNode = TreeNode::findNode(#FormsPath + "\\" + formName);
treeNode = treeNode.AOTfindChild("Data Sources");
treeNode = treeNode.AOTfindChild(tableId2Name(refTableId));
if(refFieldId)
{
newMethodName = "validate";
newMethodCode = "public boolean validate()\n{\n boolean ret;\n
;\n ret = super() && PABusInessRules::CheckRules(element, this," +
strfmt(' %1',refFieldId) + ");\n\n return ret;\n}\n";
//bus rule string is different if applied to a fieldId
busRuleString = "super() && PABusInessRules::CheckRules(element,
this," + strfmt(' %1)',refFieldId);
treeNode = treeNode.AOTfindChild("fields");
treeNode = treeNode.AOTfindChild(fieldId2Name(refTableId,RefFieldId));
}
else
{
newMethodName = "validateWrite";
newMethodCode = "public boolean validateWrite()\n{\n boolean
ret;\n ;\n ret = super() && PABusInessRules::CheckRules(element,
this);\n\n return ret;\n}\n";
busRuleString = "super() && PABusinessRules::CheckRules(element,
this)";
}
methodsTreeNode = treeNode.AOTfindChild("Methods");
treeNode = methodsTreeNode.AOTfindChild(newMethodName);
if(!treeNode)
{
methodsTreeNode.AOTadd(newMethodName);
methodsTreeNode.AOTsave();
treeNode = methodsTreeNode.AOTfindChild(newMethodName);
newSource = newMethodCode;
treeNode.AOTsetSource(newsource,false);
}
else
{
oldsource = treeNode.AOTgetSource();
// check if rule already applied
if(strscan(oldSource,busRuleString,1,strlen(oldSource)) == 0)
{
newSource = strReplace(oldsource,superString,busRuleString);
//new line to be inserted
treeNode.AOTsetSource(newsource);
}
}
TreeNode = TreeNode::findNode(#FormsPath + "\\" + formName);
treeNode.AOTcompile();
treeNode.AOTsave();
return busRuleString;
}
Tuesday, August 7, 2007
Encryption and Decryption in AX
TextBuffer textBuffer = new TextBuffer();
;
textBuffer.setText(_text);
textBuffer.encrypt(987654123); // Basic encryption
To decrypt the string again, use the following code:
TextBuffer textBuffer = new TextBuffer();
;
textBuffer.setText(_text);
textBuffer.decrypt(987654123);
decryptedString = textBuffer.getText();
Monday, July 16, 2007
valueEmptyString
myOdrTrkQBR1.value(myOrdTracking.avOrderStatus ? myOrdTracking.avOrderStatus : sysQuery::valueEmptyString());
Set Control and Keyborad Enter
public int task(int _taskId)
{
int ret;
#Task
switch (_taskId)
{
case #taskEnter :
{
if(element.selectedControl().name() == NumReceipt.name())
{
MenuItemButton.clicked();
return 0;
}
return super(_taskId);
}
default :
return super(_taskId);
}
}
Tuesday, June 5, 2007
How to base on a given string class name to create the class' instance
object CreateInstanceBaseClassName(str _className)
{
Object dialog;
DictClass DictClass;
Object classInstance;
;
DictClass = new Dictclass(classname2id(_className));
classInstance = dictclass.makeObject();
classInstance.init();
classInstance.method1; // method in the _className class, must make sure it existed
if (classInstance.prompt())
classInstance.run();
return classInstance;
}
Tuesday, May 22, 2007
How to use 'Like' syntax
{
ImportTable_ds.allowEdit(false);
ImportTable_ds.allowDelete(false);
}
else
{
ImportTable_ds.allowEdit(true);
ImportTable_ds.allowDelete(true);
}
Tuesday, April 10, 2007
What's new in Microsoft Dynamics AX 4.0 & Upgrade Methodology
Invest in flexible software architecture that can grow with your company
Published: June 12, 2006
The new version of Microsoft Dynamics AX—formerly Microsoft Axapta—can help your people be more productive, your company master change, and your business connect better to global subsidiaries, customers, and business partners. What's more, it's developed to work with widely-familiar Microsoft products, helping you leverage investments in and knowledge of technology many companies already use.
Note
Microsoft Dynamics AX 4.0 is currently available for North America and Canada. Localized versions will be released for other regions worldwide late throughout calendar year 2006 and early 2007.
On This Page
Leverage your existing technologies to boost ROI
Work more effectively across borders with new global capabilities
Get out-of-box functionality and a platform ready for development
Benefit from improved security, scalability, and performance
Next steps
*****************
*****************
http://msdn2.microsoft.com/en-us/library/aa497066.aspx
http://www.microsoft.com/dynamics/ax/product/whatsnew.mspx
Upgrade methodology --> http://msdn2.microsoft.com/en-us/library/aa497042.aspx
Sunday, March 25, 2007
"index" and "index hint"
In the Axapta community, there is still a big confusion about the "index" and "index hint" statements used in connection with selects.So, what is the Axapta kernel *really* doing:Using "index": when you add the statement "index MyIndex", the Axapta kernel will add an "ORDER BY" with all the fields of the index.Example: select * from InventTable index GroupItemIdx will generate the following SQL statement to the database:SELECT A.ITEMGROUPID, A.ITEMID, A.ITEMNAME,.... FROM INVENTTABLE A ORDER BY A.ITEMGROUPID, A.ITEMIDThe Index ItemGroupIdx of the InventTable exactly contains the two fields ItemGroupID and ItemId (in that order). Using "index", you still give the control of which index to use to the database optimizer. So, if the optimizer finds a better index to use, it will use it.Using "index hint": when you add the statement "index hint MyIndex", the Axapta kernel will add a statement to instruct the database to use that index and no other one.Example: select * from InventTable index hint GroupItemIdx will generate the following SQL statement to the database:SELECT /*+ INDEX(A I_175GROUPITEMIDX) */ A.ITEMGROUPID, A.ITEMID, A.ITEMNAME,.... FROM INVENTTABLE AUsing "index hint", you take away the control of which index to use from the database optimizer. So, if there may be a better index, the database will not use it.
Conclusion:
Adding the "index" statement to an Axapta select, it does NOT mean that this index will be used by the database. What it DOES mean is that Axapta will send an "order by" to the database.Adding the "index hint" statement to an Axapta select, it DOES mean that this index will be used by the database (and no other one).This rule applies to both the MSSQL and Oracle databases.
http://axaptafreak.blogspot.com/2005/10/mystery-of-index-vs-index-hint.htmlFriday, March 23, 2007
How to refresh FormDataSource in class.
{
common common;
formDatasource common_ds;
;
common = element.args().record();
if (common.RecId)
{
if (common.isFormDataSource())
{
common_ds = common.datasource();
if (common_ds)
{
common_ds.reread();
common_ds.refresh();
}
}
}
}