Report->Fetch method
public boolean fetch()
{
boolean ret;
CustTable custTable;
;
// ret = super();
while select crosscompany custTable
{
this.send(custTable);
}
return true;
}
This blog is for Dynamics AX (AXAPTA) Developers,this will help you for your development issues. This site contains some Microsoft Dynamics AX X++ Codes for use in your day to day use.
29 October 2010
27 October 2010
pass the parameter to report in Dynamics AX
1. Calling menuItem. Task
This is in Report to get selected record parameter like sales id ,this code is making the defalut range value the selected record of S.O -> salesId. this will pront the selected record only on report
Here we are controlling the query range prompt.
Sales Tabel form -> MenuItembutton clicked()- properties remove the menuItemName:
void clicked()
{
Args args = new Args();
MenuFunction menuFunction;
;
args.parm(SalesTable.SalesId);
menuFunction = new MenuFunction(menuitemoutputstr(Report9), MenuItemType::Output);// Report9 is menuItem
menuFunction.run(args);
super();
}
--------
In Report-> init()
public void init()
{
try
{
if(element.args().parm())
{
this.query().dataSourceTable(tablenum(SalesTable)).addRange(fieldnum(SalesTable,SalesId)).value(element.args().parm());
salesId = element.args().parm();
this.query().userUpdate(false);
this.query().interactive(false);
super();
}
}
catch(exception::Error)
{
info("Errosr in init");
}
}
-----------------------------------------------
2.calling report
form->Button
void clicked()
{
Args args = new args();
ReportRun reportRun;
;
args.parm(PurchReqTable.PurchReqId);
args.name(reportstr(PurchRequisitionDetails));
reportRun = classFactory.reportRunClass(args);
reportRun.init();
reportrun.run();
//hello
super();
}
Report and click on ‘Override Method –> init’
In this init method, you need to enter the following code to allow the report to read the parameters from the form.
public void init()
{
;
try
{
if(element.args().parm())
{
this.query().dataSourceTable(tablenum(PurchReqTable))
.addRange(fieldnum(PurchReqTable, PurchReqId)).value(element.args().parm());
this.query().userUpdate(false);
this.query().interactive(false);
super();
}
}
catch(exception::Error)
{
info(“Error in init method”);
}
}
This is in Report to get selected record parameter like sales id ,this code is making the defalut range value the selected record of S.O -> salesId. this will pront the selected record only on report
Here we are controlling the query range prompt.
Sales Tabel form -> MenuItembutton clicked()- properties remove the menuItemName:
void clicked()
{
Args args = new Args();
MenuFunction menuFunction;
;
args.parm(SalesTable.SalesId);
menuFunction = new MenuFunction(menuitemoutputstr(Report9), MenuItemType::Output);// Report9 is menuItem
menuFunction.run(args);
super();
}
--------
In Report-> init()
public void init()
{
try
{
if(element.args().parm())
{
this.query().dataSourceTable(tablenum(SalesTable)).addRange(fieldnum(SalesTable,SalesId)).value(element.args().parm());
salesId = element.args().parm();
this.query().userUpdate(false);
this.query().interactive(false);
super();
}
}
catch(exception::Error)
{
info("Errosr in init");
}
}
-----------------------------------------------
2.calling report
form->Button
void clicked()
{
Args args = new args();
ReportRun reportRun;
;
args.parm(PurchReqTable.PurchReqId);
args.name(reportstr(PurchRequisitionDetails));
reportRun = classFactory.reportRunClass(args);
reportRun.init();
reportrun.run();
//hello
super();
}
Report and click on ‘Override Method –> init’
In this init method, you need to enter the following code to allow the report to read the parameters from the form.
public void init()
{
;
try
{
if(element.args().parm())
{
this.query().dataSourceTable(tablenum(PurchReqTable))
.addRange(fieldnum(PurchReqTable, PurchReqId)).value(element.args().parm());
this.query().userUpdate(false);
this.query().interactive(false);
super();
}
}
catch(exception::Error)
{
info(“Error in init method”);
}
}
25 October 2010
Storing Last Form Values
Dynamics AX has a very useful feature, which allows saving the latest user choices per user per form. This feature is implemented across a number of standard reports, periodic jobs, and other objects, which require user input.
In this recipe, we will see how to store the latest user filter selections. To make it as simple as possible, we will use existing filters on the General journal form, which can be opened from General ledger | Journals | General journal. This form contains two filters—Show and Show user-created only. Show allows displaying journals by their posting status and Show user-created only toggles between all journals and the currently logged user's journals.
1.Find the LedgerJournalTable form in AOT, and add the following code to the bottom of its class declaration:
AllOpenPosted showStatus;
NoYes showCurrentUser;
#define.CurrentVersion(1)
#localmacro.CurrentList
showStatus,
showCurrentUser
#endmacro
------------------------------------------------
2.Create these additional form methods:
public void initParmDefault()
{
;
showStatus = AllOpenPosted::Open;
showCurrentUser = true;
}
public container pack()
{
return [#CurrentVersion,#CurrentList];
}
-----------------------------------------------------------
public boolean unpack(container packedClass)
{
int version = RunBase::getVersion(packedClass);
;
switch (version)
{
case #CurrentVersion:[version,#CurrentList] = packedClass;
return true;
default:
return false;
}
return false;
}
------------------------------------------
public identifiername lastValueDesignName()
{
return element.args().menuItemName();
}
------------------------------------------
public identifiername lastValueElementName()
{
return this.name();
}
----------------------------------------
public UtilElementType lastValueType()
{
return UtilElementType::Form;
}
----------------------------------------
public userId lastValueUserId()
{
return curuserid();
}
----------------------------------------
public dataAreaId lastValueDataAreaId()
{
return curext();
}
In this recipe, we will see how to store the latest user filter selections. To make it as simple as possible, we will use existing filters on the General journal form, which can be opened from General ledger | Journals | General journal. This form contains two filters—Show and Show user-created only. Show allows displaying journals by their posting status and Show user-created only toggles between all journals and the currently logged user's journals.
1.Find the LedgerJournalTable form in AOT, and add the following code to the bottom of its class declaration:
AllOpenPosted showStatus;
NoYes showCurrentUser;
#define.CurrentVersion(1)
#localmacro.CurrentList
showStatus,
showCurrentUser
#endmacro
------------------------------------------------
2.Create these additional form methods:
public void initParmDefault()
{
;
showStatus = AllOpenPosted::Open;
showCurrentUser = true;
}
public container pack()
{
return [#CurrentVersion,#CurrentList];
}
-----------------------------------------------------------
public boolean unpack(container packedClass)
{
int version = RunBase::getVersion(packedClass);
;
switch (version)
{
case #CurrentVersion:[version,#CurrentList] = packedClass;
return true;
default:
return false;
}
return false;
}
------------------------------------------
public identifiername lastValueDesignName()
{
return element.args().menuItemName();
}
------------------------------------------
public identifiername lastValueElementName()
{
return this.name();
}
----------------------------------------
public UtilElementType lastValueType()
{
return UtilElementType::Form;
}
----------------------------------------
public userId lastValueUserId()
{
return curuserid();
}
----------------------------------------
public dataAreaId lastValueDataAreaId()
{
return curext();
}
21 October 2010
create a new Table by using a X++ code
static void newTableCreate(Args _args)
{
TreeNode treeNode;
#AOT
;
treeNode = TreeNode::findNode(#TablesPath);
treeNode.AOTadd("Table_Test");
SqlDataDictionary::synchronize();
}
{
TreeNode treeNode;
#AOT
;
treeNode = TreeNode::findNode(#TablesPath);
treeNode.AOTadd("Table_Test");
SqlDataDictionary::synchronize();
}
18 October 2010
Created EDT with code
static void EDT_By_Code(Args _args)
{
AOTTableFieldList aTFL;
AOTTableFieldList aEDTL;
TreeNode fieldNode;
Types _enum = Types::String;
str property;
;
aEDTL = infolog.findNode('\\Data Dictionary\\Extended Data Types');
if (!aEDTL.AOTFindChild('test'))
{
aEDTL.AOTaddExtendedDataType('test', _enum);
fieldNode = aEDTL.AOTFindChild('test');
fieldNode.AOTsave();
}
property = setProperty(fieldnode.AOTgetProperties(), 'StringSize', '30');
fieldNode.AOTsave();
info(property);
fieldNode.AOTsetProperties(property);
fieldNode.AOTrefresh();
}
{
AOTTableFieldList aTFL;
AOTTableFieldList aEDTL;
TreeNode fieldNode;
Types _enum = Types::String;
str property;
;
aEDTL = infolog.findNode('\\Data Dictionary\\Extended Data Types');
if (!aEDTL.AOTFindChild('test'))
{
aEDTL.AOTaddExtendedDataType('test', _enum);
fieldNode = aEDTL.AOTFindChild('test');
fieldNode.AOTsave();
}
property = setProperty(fieldnode.AOTgetProperties(), 'StringSize', '30');
fieldNode.AOTsave();
info(property);
fieldNode.AOTsetProperties(property);
fieldNode.AOTrefresh();
}
08 October 2010
To add lookup in form control
we are adding Form control lookup Vend accountNum and Vend name
public void lookup()
{
SysTableLookup sysTableLookup;
VendTable vendTable;
;
sysTableLookup = SysTableLookup::newParameters(tablenum(VendTable), this);
sysTableLookup.addLookupfield(fieldnum(vendTable, AccountNum),true);
sysTableLookup.addLookupfield(fieldnum(vendTable, Name),true);
sysTableLookup.performFormLookup();
//super();
}
public void lookup()
{
SysTableLookup sysTableLookup;
VendTable vendTable;
;
sysTableLookup = SysTableLookup::newParameters(tablenum(VendTable), this);
sysTableLookup.addLookupfield(fieldnum(vendTable, AccountNum),true);
sysTableLookup.addLookupfield(fieldnum(vendTable, Name),true);
sysTableLookup.performFormLookup();
//super();
}
06 October 2010
WorkCalendarSched
When programming Dynamics AX it is very easy to add days to a date. You can take todays date and just add an integer of five to get the date five days from now. But because this is easy to do it doesn’t mean that this always is the right way to go about this date business.
If you look closer at how the dates are calculated on the sales order lines or the purchase order lines in Dynamics AX you see that a class called WorkCalendarSched is used. This is because deliveries are dependant on when the company using Dynamics AX actually can send the order. Not all companies work on weekends.
This is when WorkCalendarSched comes in handy, with this class and the class method “shedDate” you can make sure that the delivery is set to a day when the company actually is going to be able deliver.
This is a basic job that uses the class WorkCalendarSched and the method “shedDate”:
static void FO_stepCalendar(Args _args)
{
SchedDate schedDate;
date fromDate = systemDateGet(),
testDate;
WorkCalendarSched workCalendarSched;
int days2step = 4;
boolean calendarDays = false;
CustTable cust = CustTable::find("4000");
;
// Without using schedDate.
testDate = fromDate + days2step;
workCalendarSched = new WorkCalendarSched();
schedDate = workCalendarSched.schedDate(
SchedDirection::Forward,
fromDate,
days2step,
calendarDays,
cust.SalesCalendarId,
CompanyInfo::find().ShippingCalendarId);
print strFmt("From date: %1", fromDate);
print strFmt("Test date: %1", testDate);
print strFmt("Scheddate: %1", schedDate);
print strFmt("%1", workCalendarSched.isDateOpen(
CompanyInfo::find().ShippingCalendarId,
testDate));
print strFmt("%1", workCalendarSched.isDateOpen(
CompanyInfo::find().ShippingCalendarId,
schedDate));
pause;
}
If you look closer at how the dates are calculated on the sales order lines or the purchase order lines in Dynamics AX you see that a class called WorkCalendarSched is used. This is because deliveries are dependant on when the company using Dynamics AX actually can send the order. Not all companies work on weekends.
This is when WorkCalendarSched comes in handy, with this class and the class method “shedDate” you can make sure that the delivery is set to a day when the company actually is going to be able deliver.
This is a basic job that uses the class WorkCalendarSched and the method “shedDate”:
static void FO_stepCalendar(Args _args)
{
SchedDate schedDate;
date fromDate = systemDateGet(),
testDate;
WorkCalendarSched workCalendarSched;
int days2step = 4;
boolean calendarDays = false;
CustTable cust = CustTable::find("4000");
;
// Without using schedDate.
testDate = fromDate + days2step;
workCalendarSched = new WorkCalendarSched();
schedDate = workCalendarSched.schedDate(
SchedDirection::Forward,
fromDate,
days2step,
calendarDays,
cust.SalesCalendarId,
CompanyInfo::find().ShippingCalendarId);
print strFmt("From date: %1", fromDate);
print strFmt("Test date: %1", testDate);
print strFmt("Scheddate: %1", schedDate);
print strFmt("%1", workCalendarSched.isDateOpen(
CompanyInfo::find().ShippingCalendarId,
testDate));
print strFmt("%1", workCalendarSched.isDateOpen(
CompanyInfo::find().ShippingCalendarId,
schedDate));
pause;
}
Subscribe to:
Posts (Atom)
Merge Dimensions (MainAccountId and LedgerDimensions) defaultDimension in D365 F&O and X++
public DimensionDynamicAccount getLedgerDimension(container _conData, TransDate _transDate = today()) { int ...
-
Please click here to access Custom Workflow step by step process:
-
public InventQty onHandInventory(ItemId itemId, InventSiteId inventSiteId,InventLocationId inventLocation) { InventOnhand inventOnh...
-
1. In classDeclaration extend SrsReportDataProviderPreProcess instead of SrsReportDataProviderBase 2. Temp table properties should b...