26 December 2010

ValidateWrite

here we r validating to allow the marks field less than 100 only..

Form-DS->mothods->validateWrite()

boolean ret;
;
if(StuMarks.m1<=100)
{
ret=super();
}
else
{
info("Please enter less than 100 marks");
}
return ret;

20 December 2010

Convert the selected values from ax form to Word document template

Hi

Now you can create a user defined template and attach it to the Particular record using Document Handling feature.

Here we go
step 1: Open Microsoft Word, Create a Template / Design.
For Example: If the Field name is AccountName
Type Account Name in the word document and select Insert-> BookMark
In the Book mark Field give a name to refer that field in AX (ex: Account)
Step 2: Save the word document as a template (.dot or .dotx)
Step 3: Open AX, Basic->setup->Document Management -> Document Types
Step 4: Create New record, Type as Document, Class description as Create word document via COM, Group as Document.
Step 5: Click Options, Select the table name from the lookup (the table you want to attach the template)Ex: LedgerJournalTrans
Step 6: In the Template File field Browse and attach the template document u created in step 2.
Step 7: Click on the Fields Tab in the same form, create a new record, select the table name (same table name as step 5), Select the Data Field For Ex: Account Name
In the Book mark field enter the value, same u have given in the Word Template Bookmark. Click OK.
Step 8: Now create a Journal (EX: General Ledger -> Journals-> General Journal)
Step 9: Once u finished creating the Journal Lines, Select the Document Handling Icon in the tool bar.Create New ->Document(the name u have given in the step 4)
Step 10: Once u create the new document, the word template will open and the field value (Account Name) will be fetched in the document template. Like this u can add more fields and create bookmark and attach it with the Document types Form.

Regards
Praveen

15 December 2010

Getting Data Without Declaring a Table Variable

Its Possible to get data from the database without declaring a table variables.

Static void Job3(Args _args)
{
// No Variables
;

print (select CustTable).AccountNum;
Pause;
}

Note the parentheses around the select statement. This tells the compiler to create a temporary, anonymous buffer to hold the record. The select statement uses the exact table name and is immediately followed by a field name to get a value from a field.

If you use this there’s no Intellisense to help you look up the field name because the editor doesn’t know the type of the anonymous buffer.

This technique is often used in exist() methods on tables.

13 December 2010

In runtime look up filter the duplicate values

In runtime look up filter the duplicate values click here

To send a mail with attachments using outlook in Ax

To send a mail with attachments click here:

sysInetMail::sendEMail
smmOutlookEMail
Form-smmEncyclopedia

--
static void sendEmail(Args args)
{
smmOutlookEMail smmOutlookEMail = new smmOutlookEMail();
Object smmSendEmail;
container c;
;
args = new Args();
args.name(formstr(smmSendEmail));
args.caller(smmOutlookEMail);
smmSendEmail = classfactory.formRunClass(args);
if (smmSendEmail)
{
smmSendEmail.init();
smmSendEmail.setEmailTos("aaa@gmail.com");
smmSendEmail.setEmailSubject("Sunil");
smmSendEmail.setAttachments(["D:\SUN\I & C.pdf"]);
smmSendEmail.run();
smmSendEmail.refreshControl();
smmSendEmail.wait();
}
}

08 December 2010

To make a form in select mode ( Form in Lookup)

Which form want to open in lookup

form->methods->init()

element.selectMode(StringEdit);

Add a value to Year in date

Add a value to Year in date

static void YearInDate(Args _args)
{
Date date1,date2;
int length,day,mth,years;
;
length = 2;
date1 = systemdateget();
day = dayofmth(Systemdateget());
mth = mthofyr(SystemDateget());
years = year(SystemDateget());

date2 = mkdate(day,mth,years+length);
print date2;
pause;
}

07 December 2010

validation to allow only alphabets in textControl

validation to allow only alphabets in textControl

Form->design->StringControl->method->validate()

public boolean validate()
{
boolean ret;
;

if(strnfind(this.text(),'ABCDEFGHIJKLMNOPQRSTUVWXYZ',1,strlen(this.text())))
{
info("enter only alfa");
}
else
{
ret = super();
}
return ret;
}

Table Fields in Form Lookup / UtileElements

Table Fields in Form Lookup

Form->DS->Field->Method-> lookup()

public void lookup(FormControl _formControl, str _filterStr)
{

SysTableLookup sysTableLookup = SysTableLookup::newParameters(Tablenum(Utilelements),_formControl);
Query query = new Query();
QueryBuildDataSource QBDS;
;
SysTableLookup.addLookupfield(fieldnum(Utilelements,name));
QBDS = query.addDataSource(Tablenum(Utilelements));
QBDS.addRange(fieldnum(utilelements,recordtype)).value(queryvalue(UtilelementType::TableField));
QBDS.addRange(fieldnum(Utilelements,ParentId)).value(queryvalue(tablenum(ClinicalMaster)));

sysTableLookup.parmQuery(query);
systableLookup.performFormLookup();

//super(_formControl, _filterStr);

}

03 December 2010

Add Fields To a Table with X++ , Dynamically

Add Fields To a Table with X++ , Dynamically

There is 2 ways to create a fields for Table.

1.New Table with New Fields

2. Add New fields To Existing Table

1.Create a New Table with New Fields

static void newTableCreate112(Args _args)
{
TreeNode treeNode;
AOTTableFieldList fieldList;
#AOT
;
treeNode = TreeNode::findNode(#TablesPath);

treeNode.AOTadd("Test_ABC");

SqlDataDictionary::synchronize();

//treeNode.AOTfindChild('naresh3');

fieldList = treeNode.AOTfindChild('Test_ABC').AOTfindChild('fields');
fieldList.addString('Name');
fieldList.addInteger('Id');
fieldList.addString('Address');
fieldList.addReal('Salary');

print "Table Created";
pause;
}
2.Add New fields To Existing Table

static void newFieldCreate(Args _args)
{
TreeNode treeNode;
AOTTableFieldList fieldList;
#AOT
;
treeNode = TreeNode::findNode(@'\\Data Dictionary\Tables\Test_ABC\');
fieldList = treeNode.AOTfindChild('fields');
fieldList.addInteger('Mobile');
SqlDataDictionary::synchronize();
print "Field Created";
pause;
}

02 December 2010

Trial balance export to Azure Blob Storage

The file will be automatically generated from D365 using a batch job. The trial balance file should include all dimensions. (Main-Dept-Cost ...