31 March 2011

Dynamics Look Up Filter - task 19

One of my form's I want to display the purchase order numbers(in a drop down),whose status is "not invoiced"

Take a new form->new StringEdit control->lookup();
use the following code.
----

public void lookup()
{
PurchTable purchTable;
SysTableLookup sysTableLookup = SysTableLookup::newParameters(tablenum(PurchTable), this);
Query query = new Query();
QueryBuildDataSource queryBuildDataSource = query.addDataSource(tablenum(PurchTable));
;
sysTableLookup.addLookupfield(fieldnum(PurchTable, PurchId));
sysTableLookup.addLookupfield(fieldnum(PurchTable, PurchName));
sysTableLookup.addLookupfield(fieldnum(PurchTable,PurchStatus));
queryBuildDataSource.addRange(fieldnum(PurchTable, PurchStatus)).value(enum2str(PurchStatus::Backorder));
queryBuildDataSource.addRange(fieldnum(PurchTable, PurchStatus)).value(enum2str(PurchStatus::Received));
queryBuildDataSource.addRange(fieldnum(PurchTable, PurchStatus)).value(enum2str(PurchStatus::Canceled));
queryBuildDataSource.addRange(fieldnum(PurchTable, PurchStatus)).value(enum2str(PurchStatus::None));

sysTableLookup.parmQuery(query);
sysTableLookup.performFormLookup();
}
_______________________________________
To filter PurchId values
To avoid the null values in Dynamic lookup

public void lookup()
{
PurchTable purchTable;
SysTableLookup sysTableLookup = SysTableLookup::newParameters(tablenum(PurchTable), this);
Query query = new Query();
QueryBuildDataSource queryBuildDataSource = query.addDataSource(tablenum(PurchTable));
;
sysTableLookup.addLookupfield(fieldnum(PurchTable, PurchId));

queryBuildDataSource.addRange(fieldnum(PurchTable, PurchId)).value("000010..000020");
//To avoid the null values in Dynamic lookup
//queryBuildDataSource.addRange(fieldnum(Test_Vend,Name)).value(SysQuery::valueNotEmptyString());
//queryBuildDataSource.addRange(fieldnum(Test_Vend,Name)).value('!="" ');



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

29 March 2011

To restrict the object by calling from another object.

//To execute the code only by calling some object.

//Take a table or form. form init()-> there is some code. that code has to execute only when ever //calling by the projTable. Means that form is having DS is ProjTable. then that code has to //execute.

if (element.args().dataset() == tablenum(ProjTable))
{
// while select Regulatory
// DO the code..
}

Records get from Form in cache Records

//To get the record in form which is in currently in Datasource:
//Take a table buffer. Use the following code.

Regulatory _Regulatory ;
;
for ( _Regulatory = Regulatory_ds.getFirst(); _Regulatory; _Regulatory = Regulatory_ds.getNext())
// above line Regulatory_ds is the DataSource_DS
{
// get the records here one by one.
}

15 March 2011

Adding Find\Filter functionality on Display method

Override Context method of Form control which is using display method and provide code for filter. E.g I have done below for PhysicalInvent field of InventOnHandItem form.

void context()
{

int selectedMenu;
real test;
formrun fr;
Args ag;
Itemname strtext;
querybuilddataSource qb1;
queryrun qr;
query q;
PopupMenu menu = new PopupMenu(element.hWnd());
int a = menu.insertItem('Find');
int b = menu.insertItem('Filter');
int c = menu.insertItem('Remove Filter');


selectedMenu = menu.draw();

switch (selectedMenu)
{
case -1:
break;

case a:
ag = new args('SysformSearch');
fr = new formrun(ag);
fr.run();
fr.wait();
strtext = fr.design().controlName('FindEdit').valueStr();
if(strtext)
{
q = inventSum_Ds.query();
qb1 =q.dataSourceTable(tablenum(InventSum));
QB1.addRange(FieldNum(InventSum,PhysicalInvent)).value(SySQuery::value(strtext));
INVENTSUM_DS.query(Q);
INVENTSUM_ds.executeQuery();
}
break;

case b:
InventSum_DS.filter(FieldNum(InventSum,PhysicalInvent),Sysquery::value(InventSum.PhysicalInvent()));
break;

case c :
InventSum_DS.removeFilter();
break;

Default:
break;
}

}

09 March 2011

AX 6.0 some features in Development

Hi
All click this link to know some of the feature of Dynamics Ax 6.0 (2012)
Click Here

Current Time task 18

static void getTime(Args _args)
{
int hour,minute;
;
hour=timeNow()/3600; // return the current time only hours
minute=((timeNow() mod 3600)/60); // return the minutes
info(strfmt("Time - %1:%2",hour,minute));

}

Ledger Voucher creation Framework and x++ code to create ledger voucher

 Please click her for MS reference file Below is the out of the box example reference and code. SalesInvoiceJournalPostSubBill_Extension-...