Tuesday, September 18, 2007

How to Run Time Add Code to AOT

static str 60 addValidateCode(FormName formname, TableId refTableId, FieldId
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

Encryption and Decryption in Axapta

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

If you want to query the empty (“ ”) value in queryBuildRange, you have to use valueEmptyString.

myOdrTrkQBR1.value(myOrdTracking.avOrderStatus ? myOrdTracking.avOrderStatus : sysQuery::valueEmptyString());

Set Control and Keyborad Enter

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

// Assume the className that passed in is the runBase class name.

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

if (ImportTable.avImportId like "Z*")
{
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

What's new in Microsoft Dynamics AX 4.0
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