Skip to main content

Using Regular Expression in Ax 2009

Here i posted a small job , to explain how we use regular expressin in Axapta. Try it.

static void RegularExpression_Test()

{

int nameLength,myStringLength;

str myname = “Vasanth”;

str myString = “1234″;

str formatString , formatString1;

System.Text.RegularExpressions.Regex regEx;

System.Text.RegularExpressions.Regex regEx1;

System.Text.RegularExpressions.Match regMatch;

InteropPermission permission = new InteropPermission(InteropKind::ClrInterop);

boolean retVal, retVal1;

;

nameLength = strLen(myname);

myStringLength = strLen(myString);

formatString = strfmt(@”^[0-9]{%1}”, myStringLength);

formatString1 = strfmt(@”^[a-zA-Z ]{%1}”, nameLength);

permission.assert();

//BP Deviation documented

regEx = new System.Text.RegularExpression.Regex(formatString);

regEx1 = new System.Text.RegularExpression.Regex(formatString1);

regMatch = regEx.Match(myString);

retVal = regMatch.get_Success();

print retVal; // Returns True;

regMatch = regEx1.Match(myname);

retVal1 = regMatch.get_Success();

print retVal1 // Returns True;


}

Popular posts from this blog

Dynamics Axapta: Sales Orders & Business Connector

Well, again folllowing my same idea of writting close to nothing and pasting code, I'll paste in some code to create a sales order from some basic data and the invoice it. I'll try to explain more in the future. AxaptaObject axSalesTable = ax.CreateAxaptaObject("AxSalesTable"); AxaptaRecord rcInventDim = ax.CreateAxaptaRecord("InventDim"); AxaptaRecord rcCustTable = ax.CreateAxaptaRecord("CustTable"); rcCustTable.ExecuteStmt("select * from %1 where %1.AccountNum == '" + MySalesOrderObject.CustAccount + "'"); if (MySalesOrderObject.CurrencyCode.Trim().Length == 0) MySalesOrderObject.CurrencyCode = rcCustTable.get_Field("Currency").ToString().Trim(); string sTaxGroup = rcCustTable.get_Field("taxgroup").ToString().Trim(); //set header level fields axSalesTable.Call("parmSalesName", MySalesOrderObject.SalesName.Trim()); axSalesTable.Call("parmCustAccount", M

Passing values between form and class

Class name is EmplDuplication and Form is EmplTable . void clicked() {    MenuFunction mf;    args args = new Args();    ;     args.record(EmplTable);     mf = new menufunction(identifierstr(EmplDuplication), MenuItemType::Action); mf.run(args); } Meanwhile, in the main() method of the EmplDuplication class, we need to put this Axapta x++ code to get the datasource: static void main(Args args) {     EmplDuplication EmplDuplication; EmplTable localEmplTable; ;     if(args.record().TableId == tablenum(EmplTable)) localEmplTable = args.record();     ... }