Thursday, 27 December 2012

FactBoxes in AX 2012

FactBoxes
A FactBox is a small selection of data related to the current record in the list page.

Three types of Factbox exist:


• Info part: This has its own data source and a number of controls. It is limited in what can be displayed. However it is simple and quick to create, and can also be displayed in the Enterprise Portal.


• Form part: This is a link to a form. The form can have the same controls as a standard form. However since this is displayed in the FactBox section of the list page, adding too many controls can crowd the part.


• Cues: This is a count of a number of records related to the current record in the list page. For example, it might show the number of outstanding invoices for a customer.

Wednesday, 26 December 2012

Creating User or Importing the User in Microsoft Dynamics Ax 2012

Creating User or Importing the User in Microsoft Dynamics Ax 2012




Go to System Administration –>Users–> Users ,   click on Import the User,,

click next select the Domain and give the role by clicking next and click finish.

( You Can Create New User by clicking New User)

Select the User and click on Edit Button–>  a new Window appears

.                                                           user

 

In User’s Roles Tab :click on  Assign User Button a window appears  shown below:

select the Role and click  OK.. If  already roles Present select the role and  click delete button.

 

user2

SSRS Report Configuration

1. System Admin–> setup–>Business Intelligence–>Reporting Service–>Reporting Server

The Following Images Shows :

 

ssrsconfg

1.1) Configuration Id = MSSQLSERVER

1.2) ReportServer

servername = MTSD-01 ( system name)

server instance name = MSSQLSERVER.

1.3)  Reporting Server URL:

1.1) Report Manager URL :http://systemname/Reports

1.2) Web service URL  : http://systemname/ReportServer

1.4) Click on Validate Setting

1.5)  if it is success

 

2.  start–>adminstratot tools–>power shell

type this:

Publish-  AXReport –Id  <SSRSCONFIG-ID>  -ReportName    *, Prescription, SOReport..

 

Thursday, 20 December 2012

Difference Between Morphx and Intellimorph in Dynamics AX 2012

There are two important concepts of Dynamics AX:MorphX IDE and Intellisense.



If you want to make changes to the application you will need MorphX IDE for building, modifying tables. By simply drag and drop you can create Forms and menus. It saves your extra coding effort.  You will only need a bit of coding for advanced business logic; X++ is the programming language that is supported by MorphX IDE.



IntelliMorph is the technology that saves the design time of the developer. A  Developer only has to focus on structure not the layout. In figure bellow you can see how this feature works. Right click the workers grid and click personalize. Here you can see the user has the option to personalize the layout at run time. Developer don’t have to specify the location of the fields or the layout of the form.



intelliMorph is the Runtime Environment embedded in Microsoft Dynamics AX, that draws menus, forms, and reports for Windows- and Web-clients with the correct contents, size, and layout.
For example: 

 

1. When you use field groups, IntelliMorph can automatically update the layout of all related forms and reports whenever a modification is made to the field groups. If you create new forms or reports based on the field groups defined in the standard tables, you will not have to manually update the custom object when the standard tables are modified by an upgrade. 



2. When you create reports, it is recommended that you use the Auto design. When you use the Auto Design the IntelliMorph technology automatically adjusts the layout in your reports.


For more information on IntelliMorph, you can refer to SHANKAR DAS SHARMA Blog and the address of the blog is


http://shankard.com/microsoft-dynamics-training/morhpx-intellimorph-dynamics-ax/

Some Basics of AX

Q.     What is the use of configuration key in Ax?

Ans.   Configuration keys allow administrators to enable or disable features in the application for all users.

Disabling features helps to minimize the attack surface against potential attacks.

Q.      Where one can setup the configuration key?

Ans.   Configuration keys are applied by setting the Configuration Key property on these objects in the Application

Object Tree ( AOT ).

Q.    Can we apply a configuration key on table field and report’s control?

Ans.   Yes.

Q.    Can we create a new configuration key?

Ans.  Yes.

Q.    What is the use of security key in Ax?

Ans.  Security keys allow administrators to set security on a user group level.

Minimizing access on a user group level helps to reduce the attack surface against potential attacks.

Q.    What are all the main reasons to apply user-level security?

Ans.   Allow users to do only their designated tasks.

Protect sensitive data in the database.

Prevent users from inadvertently breaking an application by changing code or objects

on which the application depends.

Q.   What is use of AOS Authorization table property?

Ans. The AOS Authorization table property enables you to specify which data access

operations must undergo user permission checking.

Q.     What are fundamental data access operations for AOS authorization table property?

Ans.  The four fundamental data access operations are create, read, update, and delete.

These operations are represented in combinations by the following AOSAuthorization enumeration values:

         None

         CreateDelete

         UpdateDelete

         CreateUpdateDelete

         CreateReadUpdateDelete

No permission checking is done when the AOSAuthorization property is set to none.

Suppose AOSAuthorization is set to CreateDelete on a given table.

In this case, create and delete operations would be allowed to execute

only if the Application Object Server (AOS) can confirm that the user has the appropriate permissions.

Q.       What is default value of AOSAuthorization table property when a new table will be created?

Ans.   When a new table is created, its AOSAuthorization value is set to none.

 Q.    Will AOSAuthorization property be used for views?

Ans.  Yes.

Q.     What is code access security?

Ans.

1.  Code Access Security (CAS) helps protect APIs that have potential security risks when the APIs are running on

the server.

2.    CAS-enabled APIs called on the server require the use of a permission class—one of the classes derived from

CodeAccessPermission.

Q.  How data authorization in Microsoft Dynamics Ax is performed?

Ans.  Data authorization in Microsoft Dynamics AX is performed in three ways:

1. Implicit authorization .

2. Checks done by setting security properties on Application Object Tree (AOT) objects.

3.   Checks done in X++.

Q.  When there are common methods across tables, which will be the best option to create?

Ans.  Create a map and add those methods and corresponding tables.

Q.  What are the different link types available?

Ans. Active, Delayed, Passive, innerJoin, outerjoin, ExistsJoin, NotExistsJoin.

Q.   Delete Actions.

Ans.   Cascade, restricted, Cascade + restricted.

Q. Which element maintains database consistency when a record is deleted.

Ans.   Delete Action.

Q.  What will happen if one add a delete action to a table and use delete_from statement?

Ans. Database performance will be slow.

Q. Relations.

Ans. Types of relations (normal,  field fixed,  related field fixed).

Q. What is an EDT.

Ans. Extended data types (EDTs) are user-defined types.

EDTs are based on the primitive data types Boolean  integer, real, string, and date, and the composite type

container.

Extended data types are defined in the Application Object Tree (AOT) under the Data Dictionary > Extended Data

Types node.

Q. What is an index?

Ans.  An index is a table-specific database structure that speeds the retrieval of rows from the table.

Indexes are used to improve the performance of data retrieval and sometimes to ensure the existence of unique

records.

Q. What is system index?

Ans.  Microsoft Dynamics AX requires a unique index on each table so if there are no indexes on a table or all the

indexes are disabled, a system index is automatically created.

The system index is created on the RecId and DataAreaId fields if the DataAreaId field exists.

otherwise the system index is created on the RecId field. You can see system indexes in the database but they

aren't visible in the AOT.

Q. How one can create a unique index?

Ans. By setting up the “allow duplicate property” to No.

Q. Can we disable an index?

Ans.  Yes.

Today, I have posted this much of data and will post the remaining data in my leisure time.

Tuesday, 18 December 2012

Some useful code for AX Customization

You can get some useful information for this following blog....

http://archive.msdn.microsoft.com/axcodesamples

Monday, 17 December 2012

Simple UI Builder Class

This UI Builder class is simple class with less code and less effort. UI Builder Class is needed when you want to customize your dialog which pop ups when you open a Report. UI Builder Class helps you to add run time lookups and other controls on the dialog form.



Step1 : Your Class must extends SrsReportDataContractUIBuilder


class SimpleDemoUIBuilder extends SrsReportDataContractUIBuilder
{
DialogField dialogEmplId;
DialogField dialogName;
boolean enable;
SimpleDemoContract contract;

}// two fields emplId and Name will reflect in the lookup in dialog form at the time of report opening.


Step2 : Override the build method


public void build()
{
contract = this.dataContractObject();
dialogEmplId = this.addDialogField(methodStr(SimpleDemoContract, parmEmplId),contract);

}// this method used for adding the field  which is from contract class.


Step3 : Write this below code to get lookup


private void emplIdLookup(FormStringControl emplIdlookup)
{
Query query = new Query();
QueryBuildDataSource qbds_EmplTable;
SysTableLookup sysTableLookup;

// Create an instance of SysTableLookup with the current calling form control.
sysTableLookup = SysTableLookup::newParameters(tableNum(FilterDemo), emplIdlookup);
// Add fields to be shown in the lookup form.
sysTableLookup.addLookupfield(fieldNum(FilterDemo,EmplId));
sysTableLookup.addLookupfield(fieldNum(FilterDemo,Name));
qbds_EmplTable = query.addDataSource(tableNum(FilterDemo));
sysTableLookup.parmQuery(query);
// Perform the lookup
sysTableLookup.performFormLookup();
}


Step4 : Override this method



public void getFromDialog()
{
contract = this.dataContractObject();
super();
}


Step5 : Override this method


public void initializeFields()
{
contract = this.dataContractObject();
}


Step6 : Override this method


public void postBuild()
{
super();
dialogEmplId = this.bindInfo().getDialogField(this.dataContractObject(),methodStr(SimpleDemoContract,parmEmplId));dialogEmplId.registerOverrideMethod(methodStr(FormStringControl, lookup),
methodStr(SimpleDemoUIBuilder,emplIdLookup), this);dialogEmplId.lookupButton(2);
}


the Contract Class code and DP class have already been added to the blog. please check it for further reference but one important part has to be added to the contract class i.e in class declaration, the following part has to be updated.



[DataContractAttribute,SysOperationContractProcessingAttribute(classstr(SimpleDemoUIBuilder))]


Thursday, 13 December 2012

MULTI-SELECT CONTROL LOOKUP AT FORM LEVEL

Recently, i worked on the customization of form in which there is a field which has a lookup at Form level.  This lookup must select multiple fields and must reflect on the form and table as well.

This is the code at control level i.e StringEdit

public boolean modified()
{
boolean ret;
int i,l;
str temp,id;
container a;
Mzk_UAEAddress mzk;

;

ret = super();
a = ctrl.getSelectedFieldValues();
l = conLen(a);

select * from mzk;
select forUpdate Purpose from mzk where mzk.RecId == Mzk_UAEAddress.RecId;
mzk.Purpose = " ";
ttsBegin;
for(i = 1; i <= l;i++)
{

temp = conPeek(a,i);

mzk.Purpose = mzk.Purpose + temp + ",";
mzk.update();

}
ttsCommit;
return ret;
}

Print Date Time on Report

display str 70 datePage()
{;

return strfmt(element.design().lookupLabel(literalstr("@SYS10092")),
element.startDate(),
time2str(element.startTime(),-1,-1),
element.page());
}


 

Delete all the transactions

If you want to delete all the transactions done previously then you simply run this following Class

SysDatabaseTransDelete

validation of Mobile Number

public  boolean validatePhoneNumber(MobileNo    _mobileNo)
{

Str MatchEmailPattern = @"[0-9]";
System.Text.RegularExpressions.Match myMatch;
myMatch = System.Text.RegularExpressions.Regex::Match(_mobileNo,MatchEmailPattern);
return myMatch.get_Success();
}

Thursday, 6 December 2012

Simple RDP Class with Contract Class in AX 2012

1 . Firstly create contract class and specify the field which you want to provide as    parameter in the report.

2. Use this Contract class in RDP class as parameter.

3. [DataContractAttribute]

public class FilterDemoContract

{

EmplId emplId;

}

4 . [DataMemberAttribute("EmplId")]

public EmplId parmEmplId(EmplId _emplId = emplId)

{

emplId = _emplId;

   return emplId;

}

5 . Now Declare Table buffers in the Class declaration of RDP Class including Temp Table Buffer.

[SRSReportParameterAttribute(classstr(FilterDemoContract))]

class ContractDemoClass extends SRSReportDataProviderBase

{

TempFilterDemo tempFilterDemo;

FilterDemo filterDemo;

}

6. [SRSReportDataSetAttribute("TempFilterDemo")]

public TempFilterDemo getTempFIlterDemo()

{

                  select * from tempFilterDemo;

                  return tempFilterDemo;

}

7.    public void insertTmpTable()

{

tempFilterDemo.EmplId = filterDemo.EmplId;

tempFilterDemo.Name = filterDemo.Name;

tempFilterDemo.Salary = filterDemo.Salary;

tempFilterDemo.Gender = filterDemo.Gender;

tempFilterDemo.insert();

}

8. [SysEntryPointAttribute(false)]

public void ProcessReport()

{

EmplId emplId;

FilterDemoContract contract;

;

contract = this.parmDataContract() as FilterDemoContract;

emplId = contract.parmEmplId();

   select * from filterDemo where filterDemo.EmplId == emplId;

this.insertTmpTable();

}.

9. Now you left with SSRS part, in the report, one Dialog Box will popped up, there, you would enter the emplid value and report will show you that particular record.

Simple SSRS Report by RDP Class

1. Rdp Class has to extends SRSReportDataProviderBase Class.

2. It Requires one Temp Table, if the table contains more than 1000 records then Table Property TableType should be set to TempDB and if the table contains less than 1000 records then it should be set to Inmemory.

3. Firstly, Create one class which extends SRSReportDataProviderBase Class and in the Class Declaration, declare table buffers which you need including temp table buffer.

4. you can see the sample code below:

5.   class  EmpRdpClass extends SRSReportDataProviderBase

{

TempFilterDemo tempFilterDemo;

FilterDemo filterDemo;

}

6. [SRSReportDataSetAttribute("TempFilterDemo")]

public TempFilterDemo getFilterDemo()

{

    select * from tempFilterDemo;

    return tempFilterDemo;

}

7.  private void insertTmpTable()

{

whileselect * from filterDemo

{

tempFilterDemo.EmplId = filterDemo.EmplId;

tempFilterDemo.Name = filterDemo.Name;

tempFilterDemo.Salary = filterDemo.Salary;

tempFilterDemo.Gender = filterDemo.Gender;

tempFilterDemo.insert();

}

 

}

8 . [SysEntryPointAttribute(false)]

public void ProcessReport()

{

this.insertTmpTable();

}

9. Now you left with SSRS part.

Tuesday, 4 December 2012

GetProjects List in DAX

static void GetProjects(Args _args)

{

ProjectListNode projectListNode;

treenodeIterator iterator,projectiterator;

TreeNode treenodeprivate, treenodeprivateprojects, treenodeShared,   treenodesharedprojects;

int i;

;

projectListNode = infolog.projectRootNode();

treenodeprivate = projectListNode.AOTfirstChild();

iterator =treenodeprivate.AOTiterator();

setprefix(“Private projects”);

for(i = 1; i<=treenodeprivate.AOTchildNodeCount();i++)

{

treenodeprivateprojects = iterator.next();

info(findproperty(treenodeprivateprojects.AOTgetProperties(),”Name”));

}

treenodeshared = infolog.projectRootNode().AOTfindChild(‘Shared’);

projectiterator = treenodeshared.AOTiterator();

setprefix(“Shared Projects”);

for(i=1; i<= treenodeshared.AOTchildNodeCount();i++)

{

treenodesharedprojects = projectiterator.next();

info(findproperty(treenodesharedprojects.AOTgetProperties(),”Name”));

}

}

Estimating Execution Time

static void SGX_timeConsumed(Args _args)
{
FromTime startTime = timeNow();
int i;
str dummyStr;
;
for (i = 1 ; i <= 500000; i++)
{
dummyStr += int2str(i);
}
info(strFmt(“Total time consumed is  %1″, timeConsumed(startTime, timeNow())));
}

Mandatory Fields of a Table

static void mandatoryFieldsOfATable(Args _args)

{

SysDictTable sysDictTable;

SysDictField sysDictField;

TableId tableId;

Counter counter;

;

sysDictTable = new SysDictTable(tablenum(CustTable));

for(counter = 1;counter <= sysDictTable.fieldCnt(); counter++)

{

sysDictField = new sysDictField(sysDictTable.id(), sysDictTable.fieldCnt2Id(counter));

if(sysDictField.mandatory())

info(sysDictField.name());

}

Email Example

static void SendMail(Args _args)

{

SysMailer mail;

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

str from,to;

;

permission.assert();

mail = new SysMailer();

body = ” The Body of the Mail “;

from = “abc@gmail.com”;

to = “xyz@gmail.com”;

sub=”the sub of the Mail”;

mail.quickSend(from,to,sub,,body);

}

Job To Get TableIds

static void Job_To_GetTableIds(Args _args)

{

Dictionary d1;

TableId t1;

;

d1=new Dictionary();

t1=d1.tableNext(0);

while(t1)

{

info(int2str(t1));

info(tableid2Name(tableId));

t1= d1.tableNext(t1);

}

}

Job To Count Tables

static void JobToCountTables(Args _args)

{

Dictionary dict;

int totalTables;

dict=new Dictionary();

totalTables=dict.tableCnt();

info(strfmt(“%1″,totalTables));

}

Table Relations




Table level mainly 3 types of relations there…..

1)normal 2)fieldfixed 3)related fieldfixed

Normal:::To specify the relation fields without any conditions…

Fieldfixed:::To specify the relation fields to restrict the records in the” primary table”..[Means first table]

Related Fieldfixed:::To specify the relation fields to restrict the records in the “related table”….[Means Related table]

ForExample: take two tables…Custtable having Accno,Name,Gender[male,female---- male means 0 female means 1] [primary table]

CustTranse having Accno,Transdate,Amount,Paid [ yes or no-----yes means 0 no means1] this is related table

Normal—–Custtable.Accno==CustTranse .Accno

Fieldfixed—- Custtable.Gender == 0

Related Fieldfixed—- 1 == CustTranse .paid

Filtering The records in a Form

1)Create a Table Named “FilterDemo” and add some fields like Name, Eid, Salary and Add one Base Enum Like Gender.

2) Enter some Data into  the Table.

3) Create a form Name “FiletrDemoForm”.Drag the FilterDemo Table to the DataSource of the form.

4) Under the Design node of the Form.Create  a New Control àTabàTab Page.

Change the properties of the TabPage Like this

Name:- General

Caption:-General

 5) Now Add a new controlàGrid to the TabPage. Now Drag the Fields Which should Appear in the Form to the Grid control from Data Source.

6) Under the Same Tab Page Add a NewGroup. Under the New Group add a new control called ComboBox. Change the property AutoDeclaration of the comboBox to YES and BaseEnum to Gender.

7) Now the form creation is complete. Now We need to see the filtering the Record.

8) Now Declare the range In the classDeclaration of the form.

 

public class FormRun extends ObjectRun

{

QueryBuildRange range;

}

9) Add a Range in init() method of the DataSource.

public void init()

{

super();

range=this.query().dataSourceNo(1).addRange(fieldNum(FilterDemoTable,Gender));

}

10) Override the executeQuery() method of the DataSource.

public void executeQuery()

{

range.value(ComboBox.valueStr());

super();

}

11) Call the executeQuery method in the SelectionChanged method of the ComboBox.

public int selectionChange()

{

int ret;

ret = super();

FilterDemoTable_ds.executeQuery();

return ret;

}

TableDataFrom_File

static void TableDataFrom_File(Args _args)

{

commaIO commaIO;

container readLine;

Tab2 k;

FileIOPermission fio;

FileName nameOfTheFile = “c:\\anil.txt”; //csv

;

if (winapi::fileExists(nameOfTheFile) == false)

throw error(strfmt(“file %1 not found”, nameOfTheFile) );

fio = new FileIOPermission(nameOfTheFile, ‘r’);

// read – r, write – w, append – a

fio.assert(); // demand

commaIO = new commaIO(nameOfTheFile,’r');

commaIO.inFieldDelimiter(‘,’); // \t – tab, | // outFieldDelimiter commaIo.inRecordDelimiter(‘\r\n’); // OutRecorDelimiter – read line by line

ttsbegin;

if(commaIO)

{

while(commaIO.status() == IO_status::Ok)

{

readLine = commaIO.read(); //writeExp

if (conlen(readLine) > 1) // check whether there are values in the next line {

k.Address = conpeek(readLine,1); k.DName = conpeek(readLine, 2); k.insert();

}

}

}

ttscommit;

CodeAccessPermission::revertAssert();

}

Writing and Reading to a XML File

Writing to a XML File

static void writeXML(Args _args)

{

XMLTextWriter xw; FileDemo ct;

;

xw = XMLTextWriter::newFile(“c:\\FileDemo.xml”);

xw.writeStartDocument();

xw.writeStartElement(“Details”);

while select ct

{

xw.writeStartElement(“CustomerDetails”);

xw.writeElementString(“Id”,ct.Id);

xw.writeElementString(“Name”,ct.Name);

xw.writeEndElement();

}

xw.writeEndElement();

xw.writeEndDocument();

xw.close();

}

Reading from a XML File

static void readingXML(Args _args)

{

XMLDocument xmlDoc = XMLDocument::newFile(“c:\\FileDemo.xml”);

int i, nooftags;

;

nooftags = xmlDoc.getElementsByTagName(“CustomerDetails”).length();

for(i=0; i<nooftags; i++)

{

info(strfmt(“%1″, xmlDoc.getElementsByTagName(“Id”).item(i).text()));

info(strfmt(“%1″, xmlDoc.getElementsByTagName(“Name”).item(i).text()));

}

}

File Handling in DAX 2012

Writing to a Text File

static void textFileWrite(Args _args)

{

TextBuffer tb = new TextBuffer();

;

tb.appendText(“Hello World!”);

tb.appendText(“\nWelcome to MIT”);

tb.appendText(“\nHyderabad”);

tb.toFile(“c:\\Sample.txt”);

}

Reading from a Text File

static void textFileRead(Args _args)

{

TextBuffer tb = new TextBuffer();

;

if(WinApi::fileExists(“c:\\Sample.txt”))

{

tb.fromFile(“c:\\Sample.txt”);

info(tb.getText());

}

else

{

info(“No file exists”);

}

}

EnumConversion in DAX

static void EnumConversion(Args _args)

{

AccountType type;

EnumId e=enumNum(AccountType);

DictEnum denum = new DictEnum(e);

int cnum = denum.values();

int c;

int i;

for(c=0;c<cnum;c++)

{

denum.name();

denum.index2Value(c);

denum.index2Symbol(c);

info(strFmt(“%1″,denum.index2Label(c)));

}

for(i=0;i<4;i++)

{

info(strFmt(“%1″,type));

}

}

Number Validation

static void TextBuffer_regularExpression(Args _args)

{

TextBuffer txt = new TextBuffer();

str msg = “98797897″;

;

txt.setText(msg);

txt.regularExpressions(true);   // activate regular expr in search

// Regular expression to validate only digits

if (txt.find(“^[0-9]+$”))

{

info(“string contains only numbers”);

}

}

URL Validation

Static Server boolean validateURL(URL _url)
{
Boolean valid;
Boolean xppBool;
System.Boolean netBool;

Str matchURLPattern = “^(https?://)”
+ “?(([0-9a-z_!~*'().&=+$%-]+: )?[0-9a-z_!~*'().&=+$%-]+@)?” //user@+ @”(([0-9]{1,3}\.){3}[0-9]{1,3}” // IP- 199.194.52.184+ “|” // allows either IP or domain+ @”([0-9a-z_!~*'()-]+\.)*” // tertiary domain(s)- www.+ @”([0-9a-z][0-9a-z-]{0,61})?[0-9a-z]\.” // second level domain+ “[a-z]{2,6})” // first level domain- .com or .museum+ “(:[0-9]{1,4})?” // port number- :80+ “((/?)|” // a slash isn’t required if there is no file name+ “(/[0-9a-z_!~*'().;?:@&=+$,%#-]+)+/?)$”;

System.Text.RegularExpressions.Match myMatch;

new InteropPermission(InteropKind::ClrInterop).assert();

myMatch = System.Text.RegularExpressions.Regex::Match(_url,matchURLPattern);

netBool = myMatch.get_Success(); xppBool = netBool;

CodeAccessPermission::revertAssert(); Return xppBool;

}

Email validation

Static Server boolean validateEMail(EMail _eMail)

{

Boolean valid; Boolean xppBool;

System.Boolean netBool;

Str MatchEmailPattern = @”^(([\w-]+\.)+[\w-]+|([a-zA-Z]{1}|[\w-]{2,}))@”+ @”((([0-1]?[0-9]{1,2}|25[0-5]|2[0-4][0-9])\.([0-1]?[0-9]{1,2}|25[0-5]|2[0-4][0-9])\.”+ @”([0-1]?[0-9]{1,2}|25[0-5]|2[0-4][0-9])\.([0-1]?[0-9]{1,2}|25[0-5]|2[0-4][0-9])){1}|”+ @”([a-zA-Z]+[\w-]+\.)+[a-zA-Z]{2,4})$”;

System.Text.RegularExpressions.Match myMatch;

new InteropPermission(InteropKind::ClrInterop).assert();

myMatch = System.Text.RegularExpressions.Regex::MatchnetBool = (_eMail,MatchEmailPattern);

myMatch.get_Success(); xppBool = netBool;

CodeAccessPermission::revertAssert(); Return xppBool;

}

Class2XML conversion

static void Class2XML(Args _args)


{


TreeNode    treeNode = TreeNode::findNode(@’\Classes\abValidation’);


TreeNode    childNode;


str nodename, code;


int  counter=1;


Boolean     foundObject;


XMLDocument xmlDoc;


XMLTextWriter xw;

;

xw = XMLTextWriter::newFile(“c:\\abValidation.xml”);

//pass treeNode.AOTname() name to create a xml with the class name xw.writeStartDocument();

if (treeNode)

{

xw.writeStartElement(treeNode.AOTname());

childNode = treeNode.AOTfirstChild();

while(counter <= treeNode.AOTchildNodeCount())

{

nodename = “”;

if(childNode)

{

nodename = childNode.treeNodeName();

if(childNode.treeNodeName())

{

xw.writeStartElement(nodename);

xw.writeElementString(“Data”,childNode.AOTgetSource());

xw.writeEndElement();

}

}

childNode = childNode.AOTnextSibling(); counter++;

}

xw.writeEndElement();

xw.writeEndDocument();

xw.close();

}

Box::info(“Xml Created Successfully”);

}

Xml2Class Conversion

static void Xml2Class(Args _args)

{

#define.paramsNode(“abValidation”)

XmlDocument xmlDoc;

XmlElement xmlRoot;

XmlElement xmlField;

XmlElement xmlRecord;

XmlNodeList xmlRecordList;

XmlNodeList xmlFieldList;

ClassBuild  classBuild;

DictClass   dictClass;

int i, j;

;

xmlDoc = new XmlDocument(); xmlDoc.load(@”c:\\abValidation.xml”); xmlRoot = xmlDoc.getNamedElement(#paramsNode); xmlRecordList = xmlRoot.childNodes(); classBuild = new ClassBuild(“abValidation_demo”, false);

for (i=0; i<xmlRecordList.length(); i++)

{

xmlRecord = xmlRecordList.item(i);

xmlFieldList = xmlRecord.childNodes();

for (j=0; j<xmlFieldList.length(); j++)

{

xmlField = xmlFieldList.item(j);

classBuild.addMethod(xmlRecord.baseName(),xmlField.innerText());

}

}

}

Difference between this and element

When writing code in X++ you sometimes need to reference this.functionYouWant() and sometimes it is element.FunctionYouWant(). Sometimes both are in scope. I often try one and if the function I want isn’t there I try the other. Is there a rule that explains when to use “this” and when to use “element”?

“this” can be used in any objects to reference the current object and member methods.

MorphX forms and reports are composite objects.

In forms the collection of objects is contained within a FormRun object. You can reference members in the outer FormRun object by using the “element” reference.

If your code is placed at the top level there are no functional difference between “this” and “element”.

If your code is placed in a FormDataSource “this” will reference the datasource but “element” will reference the “FormRun”.

Creating Form through X++

static void CreateFormThroughCode(Args _args)

{ Form                   form; FormRun             formRun; Args                    args; FormBuildDesign         formBuildDesign; FormBuildControl        formBuildControl; FormBuildTabControl     formBuildTabControl; FormBuildTabPageControl formBuildTabPageControl; FormBuildGridControl    formBuildGridControl; FormBuildDatasource     formBuildDatasource; FormBuildStringControl  formString; ;

form = new Form(); formBuildDatasource = form.addDataSource(tableStr(PurchTable)); formBuildDesign = form.addDesign(“design”); formBuildTabControl = formBuildDesign.addControl(FormControlType::Tab, “Tab”); formBuildTabPageControl = formBuildTabControl.addControl(FormControlType::TabPage, “TabPage”); formBuildGridControl = formBuildTabPageControl.addControl(FormControlType::Grid, “Grid”); formString = formBuildGridControl.addDataField(formBuildDatasource.id(), fieldNum(PurchTable, PurchId)); formString.label(“PurchId”); formString = formBuildGridControl.addControl(FormControlType::Real,”Anil”); formString.label(“Anil”);

args    = new Args(); args.object(form); formRun = classFactory.formRunClass(args); formRun.init(); formRun.run(); formRun.wait(); }