The purpose of this blog is for knowledge sharing and connect the relevant audience who are all into Microsoft Dynamics world.
Alfasith AX
Showing posts with label Form work. Show all posts
Showing posts with label Form work. Show all posts
Monday, December 9, 2013
Tuesday, November 26, 2013
Adding image through external resource for Dynamic AX 2012
How to use resource files in Axapta
In AOT, you can find resources node
Select resources node and right click; select Create from File, specify the file location for the new resource
file. After that you can use this resource file in Axapta without specifying an absolute file path in your
local/server system.
First, pick up the resource node from AOT;
SysResource::getResourceNode();
Then generate a temporary file for this resource file;
SysResource::saveToTempFile()
Finally specify the temporary file path for controls.
First, pick up the resource node from AOT;
SysResource::getResourceNode();
Then generate a temporary file for this resource file;
SysResource::saveToTempFile()
Finally specify the temporary file path for controls.
Here comes an example to show how to use a resource file as a background image of a given form.
{
ResourceNode resourceNode;
FilePath imagename;
;
resourceNode = SysResource::getResourceNode(resourcestr(ResourceName));
if (resourceNode)
{
resourceNode. AOTload();
imagename = SysResource::saveToTempFile(resourceNode);
}
else
{
throw Error(“No file exists.”)
}
element.design().imageName(imagename);
}
Example:
You can try "Resources" node to achieve your requirement.
Just Add a new resources under "Resources" node in AOT, than use following X++ code to access that image..
SysResource::getResourceNodeData(SysResource::getResourceNode('theaxapta_File'));
Thursday, October 24, 2013
Vertical splitter in forms (Dynamic AX 2012)
Hi,
1. Create a group inside the main group
note: between the two groups
2. In property window of that group
Autodeclaration :Yes
Style : SplitterVerticalContainer
3.In the class declaration of that form use below code
public class FormRun extends ObjectRun
{
SysFormSplitter_X m_vSplitter;
}
4. In the init method of the form use below code pattern
public void init()
{
;
super();
m_vSplitter = new SysFormSplitter_X(vSplitter, gridContainer, element);
}
1. Create a group inside the main group
note: between the two groups
2. In property window of that group
Autodeclaration :Yes
Style : SplitterVerticalContainer
3.In the class declaration of that form use below code
public class FormRun extends ObjectRun
{
SysFormSplitter_X m_vSplitter;
}
4. In the init method of the form use below code pattern
public void init()
{
;
super();
m_vSplitter = new SysFormSplitter_X(vSplitter, gridContainer, element);
}
Tuesday, October 22, 2013
Display message when empty report "No data found in SSRS"
In the property window os Visual studio (SSRS)
check 'NoRowsMessage' property for tablix. You can set this property to show a
custom message when no row is returned.
NORowsMessage = "No data available for current
filter selection" //user defined msg that is to be displayed
You can also specify the specific font style like
size, color, format etc.
Add a text box with expression
=IIF(Count(<SomeId Field>,"DataSet1")=0,"No Data
Returned", nothing)
Or
set the visibility of this textbox as
=IIF(Count(<SomeId Field>,"DataSet1")=0,False,True)
In the table header (header fields), use expression
for each of the column headers to Set the visibility to false so that the end user
won’t be able to see the table header when there is no data.
Sunday, September 22, 2013
Send task msg from current outlook in Dynamic AX
Hi,
static void AppointmentFrom
Outlook(Args _args)
{
COM sysOutlookCollection;
COM receipiants;
COM collection;
COMVariant comStartDate = new COMVariant();
COMVariant comEndDate = new COMVariant();
COM c;
#SysOutLookCOMDEF
#define.mapi("MAPI")
#define.outlook("Outlook.Application")
COM sysOutlook;
COM sysOutlookNameSpace;
COM sysOutlookMAPIFolder;
sysOutlook = new COM(#outlook);
sysOutlookNameSpace = sysOutlook.getNamespace(#mapi);
sysOutlookNameSpace.logon();
sysOutlookMAPIFolder = sysOutlookNameSpace.getDefaultFolder(#OlDefaultFolders_olFolderTasks);
collection = sysOutlookMAPIFolder.items();
c = collection.add();
comStartDate.date(today());
comStartDate.time(str2Time( "12:00:00"));
comEndDate.date(today());
comEndDate.time(str2Time( "12:15:00"));
c.subject("This is the subject");
c.body("Body of that msg");
c.save();
if (c)
{
receipiants = c.Recipients();
receipiants.add("mdalfasith@gmail.com");
receipiants.ResolveAll();
c.assign();
//c.display();
c.send();
info("Success msg in AX");
}
else
throw error("@SYS31969");
sysOutlookNameSpace.logoff();
}
Friday, September 6, 2013
Validate an enum in Dynamic AX
Validate an enum
if(NetOccupied.valueStr() == enum2str(NetOccupied::Vacant))
CreateReservation.enabled(true);
else
CreateReservation.enabled(false);
if(NetOccupied.valueStr() == enum2str(NetOccupied::Vacant))
CreateReservation.enabled(true);
else
CreateReservation.enabled(false);
Friday, August 30, 2013
Tuesday, August 27, 2013
To print only Today's date in Dynamic AX
job:,
date d;
d = today();
info(date2str(d,123,-1,-1,-1,-1,-1));
date d;
d = today();
info(date2str(d,123,-1,-1,-1,-1,-1));
Monday, August 5, 2013
lookup with joinning 2 tables in Dynamic AX
Implement this code in the lookup() method of the field where you need the lookup to be displayed.
NS: The same code can be written in three places to achieve the lookup.
1) Under AOT->Table->Method and cal this method from the form design where you want to display the lookup.
2) Form->Datasource->Table->Field->method
3) Form->Design->Field->Method.
public void lookup()
{
Query query = new Query();
QueryBuildDataSource qbds;
QueryBuildDataSource QbdsJoin;
// Instantiate sysTableLookup object using table which will provide the visible fields
SysTableLookup sysTableLookup = sysTableLookup::newParameters(tableNum(TableName), this);
;
// Create the query.
qbds= query.addDataSource(tableNum(TableName));
qbds.addRange(fieldNum(TableName, FieldName)).value('Value');
//Join Table
QbdsJoin= qbds.addDataSource(tableNum(TableName2));
QbdsJoin.relations(true);
QbdsJoin.joinMode(JoinMode::ExistsJoin);
QbdsJoin.addRange(fieldNum(TableName2, Fieldname)).value('Value');
// Set the query to be used by the lookup form
sysTableLookup.parmQuery(query);
// Specify the fields to show in the form.
sysTableLookup.addLookupfield(fieldNum(TableName, FiledName));
sysTableLookup.addLookupfield(fieldId2Ext(fieldNum(TableName, Dimension), 1));
// Perform the lookup
sysTableLookup.performFormLookup();
}
NS: The same code can be written in three places to achieve the lookup.
1) Under AOT->Table->Method and cal this method from the form design where you want to display the lookup.
2) Form->Datasource->Table->Field->method
3) Form->Design->Field->Method.
public void lookup()
{
Query query = new Query();
QueryBuildDataSource qbds;
QueryBuildDataSource QbdsJoin;
// Instantiate sysTableLookup object using table which will provide the visible fields
SysTableLookup sysTableLookup = sysTableLookup::newParameters(tableNum(TableName), this);
;
// Create the query.
qbds= query.addDataSource(tableNum(TableName));
qbds.addRange(fieldNum(TableName, FieldName)).value('Value');
//Join Table
QbdsJoin= qbds.addDataSource(tableNum(TableName2));
QbdsJoin.relations(true);
QbdsJoin.joinMode(JoinMode::ExistsJoin);
QbdsJoin.addRange(fieldNum(TableName2, Fieldname)).value('Value');
// Set the query to be used by the lookup form
sysTableLookup.parmQuery(query);
// Specify the fields to show in the form.
sysTableLookup.addLookupfield(fieldNum(TableName, FiledName));
sysTableLookup.addLookupfield(fieldId2Ext(fieldNum(TableName, Dimension), 1));
// Perform the lookup
sysTableLookup.performFormLookup();
}
Validating two date fields in Dynamic AX
Hi,
1.Create two fields as UtcDateTimeEdit of table TableName
2.Name it InTime and OutTime.
3.In the init() of that datasource or form depends on requirements.
TableName.InTime = DateTimeUtil::getSystemDateTime();
TableName.OutTime = DateTimeUtil::getSystemDateTime();
//here making the system date and time to the that field.
3.Override the modified method by modified each of the fields.
public boolean modified()
{
boolean ret;
ret = super();
if(SMAServiceOrderTable.InTime > SMAServiceOrderTable.OutTime)
{
warning("In time cannot be greater than Out time");
SMAServiceOrderTable.InTime = DateTimeUtil::getSystemDateTime();
SMAServiceOrderTable.OutTime = DateTimeUtil::getSystemDateTime();
}
return ret;
}
1.Create two fields as UtcDateTimeEdit of table TableName
2.Name it InTime and OutTime.
3.In the init() of that datasource or form depends on requirements.
TableName.InTime = DateTimeUtil::getSystemDateTime();
TableName.OutTime = DateTimeUtil::getSystemDateTime();
//here making the system date and time to the that field.
3.Override the modified method by modified each of the fields.
public boolean modified()
{
boolean ret;
ret = super();
if(SMAServiceOrderTable.InTime > SMAServiceOrderTable.OutTime)
{
warning("In time cannot be greater than Out time");
SMAServiceOrderTable.InTime = DateTimeUtil::getSystemDateTime();
SMAServiceOrderTable.OutTime = DateTimeUtil::getSystemDateTime();
}
return ret;
}
Wednesday, July 24, 2013
Creating the Query in job - Dynamic AX
static void CustTableSales1(Args _args)
{
Query query;
QueryRun queryrun;
QueryBuildDataSource qbds1,qbds2;
QueryBuildRange qbr1,qbr2;
CustTable custTable;
;
query = new query();
qbds1 = query.addDataSource(tablenum(CustTable));
qbds1.addSortField(fieldnum(custTable,AccountNum),Sortorder::Descending);
qbr1 = qbds1.addRange(fieldnum(custTable,custGroup));
qbr1.value(queryvalue('10'));
qbr2 = qbds1.addRange(fieldnum(custTable,Blocked));
qbr2.value(queryvalue(CustVendorBlocked::No));
qbds2 = qbds1.addDataSource(tablenum(SalesTable));
qbds2.relations(false);
qbds2.joinMode(joinmode::ExistsJoin);
qbds2.addLink(fieldnum(CustTable,AccountNum),fieldnum(SalesTable,CustAccount));
queryrun = new queryrun(query);
while(queryrun.next())
{
custTable = queryrun.get(tablenum(custTable));
info(strfmt('%1 – %2',custtable.AccountNum,custTable.name()));
}
}
//Another sample code///
{
Query query;
QueryRun queryrun;
QueryBuildDataSource qbds1,qbds2;
QueryBuildRange qbr1,qbr2;
CustTable custTable;
;
query = new query();
qbds1 = query.addDataSource(tablenum(CustTable));
qbds1.addSortField(fieldnum(custTable,AccountNum),Sortorder::Descending);
qbr1 = qbds1.addRange(fieldnum(custTable,custGroup));
qbr1.value(queryvalue('10'));
qbr2 = qbds1.addRange(fieldnum(custTable,Blocked));
qbr2.value(queryvalue(CustVendorBlocked::No));
qbds2 = qbds1.addDataSource(tablenum(SalesTable));
qbds2.relations(false);
qbds2.joinMode(joinmode::ExistsJoin);
qbds2.addLink(fieldnum(CustTable,AccountNum),fieldnum(SalesTable,CustAccount));
queryrun = new queryrun(query);
while(queryrun.next())
{
custTable = queryrun.get(tablenum(custTable));
info(strfmt('%1 – %2',custtable.AccountNum,custTable.name()));
}
}
//Another sample code///
Query query; QueryRun queryRun; QueryBuildDataSource queryBuildDataSource; QueryBuildRange queryBuildRange; CustTable custTable; query = new Query(); queryBuildDataSource = query.addDataSource(TableNum(CustTable)); queryBuildRange = queryBuildDataSource.addRange(FieldNum(CustTable,AccountNum)); queryBuildRange.value("4000..5000"); queryRun = new queryRun(query); if (queryRun.prompt()) { while (queryRun.next()) { custTable = queryRun.get(TableNum(CustTable)); print custTable.AccountNum; } }
Monday, July 22, 2013
Difference between two dates in days in Dynamic AX
To get the difference between two dates in dynamics ax just convert the dates into numbers and subtract one from the other. The result would be the amount of days between these dates.
days = date2num(Date123) - date2num(Date234);
To get the difference between two DateTime Values just use the DateTimeUtil Class. The result is the difference in seconds. So just divide these through #secondsPerDay and you'll get the days
#timeConstants
days = DateTimeutil::getDifference(DateTime123, DateTime234) / #secondsPerDay;
today() - mkdate(31,01,2011) ;
or
days = date2num(Date123) - date2num(Date234);
or
TblName.FieldName= date2num(today()) - date2num(AnotherTblName.DatefeildName);
To get the difference between two DateTime Values just use the DateTimeUtil Class. The result is the difference in seconds. So just divide these through #secondsPerDay and you'll get the days
#timeConstants
days = DateTimeutil::getDifference(DateTime123, DateTime234) / #secondsPerDay;
-------------------------------------------------------------------
date2num(systemdateget()) - date2num(urtable.date);
---------------------------------------------------------------------------------------------------------
static void DateDiff(Args _args)
{
TransDate d1,d2;
int daysdiff;
;
d1 = 31\12\2010;
d2 = today();
daysDiff = d2 - d1;
info(strfmt("%1",daysDiff));
}
{
TransDate d1,d2;
int daysdiff;
;
d1 = 31\12\2010;
d2 = today();
daysDiff = d2 - d1;
info(strfmt("%1",daysDiff));
}
-----------------------------------------------------------------------------------------------------
Or just override the field in datasource level as modified()
then
tablename.fieldName3 = tablename.fieldName2 - tablename.fieldName1;
filedName1 - Out put field,
filedName2 - To date field,
filedName2 - from date field,
Or just override the field in datasource level as modified()
then
tablename.fieldName3 = tablename.fieldName2 - tablename.fieldName1;
filedName1 - Out put field,
filedName2 - To date field,
filedName2 - from date field,
Saturday, July 13, 2013
File Handling in Dynamic AX
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”);
{
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();
;
{
TextBuffer tb = new TextBuffer();
;
if(WinApi::fileExists(“c:\\Sample.txt”))
{
tb.fromFile(“c:\\Sample.txt”);
info(tb.getText());
}
else
{
info(“No file exists”);
}
}
{
tb.fromFile(“c:\\Sample.txt”);
info(tb.getText());
}
else
{
info(“No file exists”);
}
}
Writing to a CSV File
static void cSVFileWrite(Args _args)
{
CommaIO commaIO;
Container readCon;
FileIOPermission fio;
FileDemo ct;
;
{
CommaIO commaIO;
Container readCon;
FileIOPermission fio;
FileDemo ct;
;
commaIO = new CommaIO(“c:\\FileDemo.csv”, “w”);
commaIO.outFieldDelimiter(“,”);
commaIO.outRecordDelimiter(“\r\n”);
commaIO.outFieldDelimiter(“,”);
commaIO.outRecordDelimiter(“\r\n”);
if(commaIO)
{
while select ct
{
commaIO.write(ct.Id,ct.Name);
}
}
}
{
while select ct
{
commaIO.write(ct.Id,ct.Name);
}
}
}
Reading from a CSV File
static void cSVFileRead(Args _args)
{
CommaIO commaIO;
Container readCon;
FileIOPermission fio;
FileDemo ct;
;
if(!WinAPI::fileExists(“c:\\FileDemo.csv”))
{
throw error(“File not available”);
}
{
CommaIO commaIO;
Container readCon;
FileIOPermission fio;
FileDemo ct;
;
if(!WinAPI::fileExists(“c:\\FileDemo.csv”))
{
throw error(“File not available”);
}
fio = new FileIOPermission(“c:\\FileDemo.csv”, “r”);
fio.assert();
fio.assert();
commaIO = new CommaIO(“c:\\FileDemo.csv”, “r”);
commaIO.inFieldDelimiter(“,”);
commaIO.inRecordDelimiter(“\r\n”);
commaIO.inFieldDelimiter(“,”);
commaIO.inRecordDelimiter(“\r\n”);
if(commaIO)
{
while(CommaIO.status() == IO_Status::Ok)
{
readCon = commaIO.read();
if(conlen(readcon) > 0)
{
ct.Id = conpeek(readcon, 1);
ct.Name = conpeek(readcon, 2);
ct.insert();
}
}
}
}
{
while(CommaIO.status() == IO_Status::Ok)
{
readCon = commaIO.read();
if(conlen(readcon) > 0)
{
ct.Id = conpeek(readcon, 1);
ct.Name = conpeek(readcon, 2);
ct.insert();
}
}
}
}
Writing to a XML File
static void writeXML(Args _args)
{
XMLTextWriter xw;
FileDemo ct;
;
{
XMLTextWriter xw;
FileDemo ct;
;
xw = XMLTextWriter::newFile(“c:\\FileDemo.xml”);
xw.writeStartDocument();
xw.writeStartDocument();
xw.writeStartElement(“Details”);
while select ct
{
xw.writeStartElement(“CustomerDetails”);
xw.writeElementString(“Id”,ct.Id);
xw.writeElementString(“Name”,ct.Name);
xw.writeEndElement();
}
{
xw.writeStartElement(“CustomerDetails”);
xw.writeElementString(“Id”,ct.Id);
xw.writeElementString(“Name”,ct.Name);
xw.writeEndElement();
}
xw.writeEndElement();
xw.writeEndDocument();
xw.close();
}
xw.writeEndDocument();
xw.close();
}
Reading from a XML File
static void readingXML(Args _args)
{
XMLDocument xmlDoc = XMLDocument::newFile(“c:\\FileDemo.xml”);
int i, nooftags;
;
{
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()));
}
}
{
info(strfmt(“%1″, xmlDoc.getElementsByTagName(“Id”).item(i).text()));
info(strfmt(“%1″, xmlDoc.getElementsByTagName(“Name”).item(i).text()));
}
}
TableData_to_File
static void TableData_to_File(Args _args)
{
commaIO commaIO;
container readLine;
CustTable k;
{
commaIO commaIO;
container readLine;
CustTable k;
FileIOPermission fio;
FileName nameOfTheFile = “c:\\anil.txt”; //csv
;
fio = new FileIOPermission(nameOfTheFile, ‘w’);// read – r, write – w, append – a
fio.assert(); // demand
FileName nameOfTheFile = “c:\\anil.txt”; //csv
;
fio = new FileIOPermission(nameOfTheFile, ‘w’);// read – r, write – w, append – a
fio.assert(); // demand
commaIO = new commaIO(nameOfTheFile,’w');
commaIO.outFieldDelimiter(‘,’); // \t | // outFieldDelimiter
commaIo.outRecordDelimiter(‘\r\n’); // OutRecorDelimiter
commaIo.outRecordDelimiter(‘\r\n’); // OutRecorDelimiter
commaIO.writeExp(["Accno",
"AccountStatement",
"CommissionGroup","DefaultDimention"]);
while select k
{
commaIO.writeExp([k.AccountNum,
k.AccountStatement,k.CommissionGroup,k.DefaultDimension]);
}
{
commaIO.writeExp([k.AccountNum,
k.AccountStatement,k.CommissionGroup,k.DefaultDimension]);
}
CodeAccessPermission::revertAssert();
}
}
TableDataFrom_File
static void TableDataFrom_File(Args _args)
{
commaIO commaIO;
container readLine;
Tab2 k;
{
commaIO commaIO;
container readLine;
Tab2 k;
FileIOPermission fio;
FileName nameOfTheFile = “c:\\anil.txt”; //csv
;
FileName nameOfTheFile = “c:\\anil.txt”; //csv
;
if (winapi::fileExists(nameOfTheFile) == false)
throw error(strfmt(“file %1 not found”, nameOfTheFile) );
throw error(strfmt(“file %1 not found”, nameOfTheFile) );
fio = new FileIOPermission(nameOfTheFile, ‘r’);// read – r,
write – w, append – a
fio.assert(); // demand
fio.assert(); // demand
commaIO = new commaIO(nameOfTheFile,’r');
commaIO.inFieldDelimiter(‘,’); // \t – tab, | //
outFieldDelimiter
commaIo.inRecordDelimiter(‘\r\n’); // OutRecorDelimiter – read line by line
commaIo.inRecordDelimiter(‘\r\n’); // OutRecorDelimiter – read line by line
ttsbegin;
if(commaIO)
{
while(commaIO.status() == IO_status::Ok)
{
readLine = commaIO.read(); //writeExp
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();
{
k.Address = conpeek(readLine,1);
k.DName = conpeek(readLine, 2);
k.insert();
}
}
}
}
}
ttscommit;
CodeAccessPermission::revertAssert();
}
}
Wednesday, July 10, 2013
Passing the records between the forms Dynamic AX
Hi
1.
Create a formA with datasource as CustTable and
grid in the design with the same datasource and one button.
2.
Overrode the clicked method of button in FormA
void
Clicked()
{
Args _args;
FormRun
_formRun;
AccountNum _accountNum;
;
_accountNum
= CustTable.AccountNum; // Selected AccountNum in the Grid is assigned to the
variable which is pass to the next form
_args
= new Args(); // creating a object for args class
_args.name(formstr(CustomerSelectionRecordsA)); // Form Menuitem
_args.caller(this); // Form
Caller(Current Form is mentioned as this)
_args.parm(_accountNum);
// Employee Number is passed to next form[but
parm() is not a best practise]
_args.record(CustTable);
// Table name is passed
_formRun
= ClassFactory.formRunClass(_args); //new FormRun(_args); // Creating object for FormRun
_formRun.init(); // Form
Initialization for Load
_formRun.run(); // Form Run for
process
_formRun.wait();
// Form Wait for Display
}
3.
4.
Create another formB with same as formA design.
5.
Override the init() of the formB
public void
init()
{
parmid
_parmId;
CustTable
_CustTable;
// DictTable
_dictTable;
FormBuildDataSource _ds; FormBuildGridControl frmGrid; // These are
for dynamicForm creation so leave it
_parmId =
element.args().parm(); // Getting the
argument value from the Caller
//info(int2str(element.args().record().TableId));
if(!element.args().caller()) // Check the
form is called by caller or directly, if directly it throw error
throw error('Cant
Run Directly');
if(element.args().record().TableId
== tablenum(CustTable)) // check if the
sent Table and the Current form table are equal or not
{
// _EmplTable =
element.args().record(); // Assign the
Received Table name to Local Variable
//_dictTable = new
DictTable(element.args().record().TableId);
// leave it , is used for Dynamic Form Creation
//_ds =
form.addDataSource(_dictTable.name());
// leave it , is used for Dynamic Form Creation
//_ds.table(_dictTable.id()); // leave it , is used for Dynamic Form Creation
//frmGrid =
form.addControl(FormControlType::Grid, “Grid”); // leave it , is used for Dynamic Form
Creation
//frmGrid.dataSource(_ds.name()); // leave it , is used for Dynamic Form
Creation
//info(strfmt(“%1 %2″,_EmplTable.EmplId,_EmplTable.DEL_Name));
//frmGrid.addDataField(_ds.id(),fieldnum(EmplTable,
DEL_Name)); // leave it , is used for
Dynamic Form Creation
//
EmplTable_EmplId.dataSource(_EmplTable); // leave it , is used for Dynamic Form
Creation
// EmplTable_EmplId.dataField(fieldnum(EmplTable,EmplID)); // leave it , is used for Dynamic Form
Creation
//
EmplTable_DEL_Name.dataSource(_EmplTable); // leave it , is used for Dynamic Form
Creation
//
EmplTable_DEL_Name.dataField(fieldnum(EmplTable,EmplId)); // leave it , is used for Dynamic Form
Creation
//
EmplTable_DEL_Email.dataSource(_EmplTable); // leave it , is used for Dynamic Form
Creation
//
EmplTable_DEL_Email.dataField(fieldnum(EmplTable,EmplId)); // leave it , is used for Dynamic Form
Creation
super(); // Form
Initialization
}
else
{
info('DataSet Not
Received'); // throw error
}
}
6.
Override the init() of the datasource of the
form table that we used ie CustTable
public
void init()
{
Query query;
QueryBuildRange queryBuildRangeProj;
switch(element.args().dataset())// get the table id sent by caller
{
case
tablenum(CustTable): // check the
table if matches with this tableid
{
_AccountNum =
element.args().parm(); // get the argument value
query
= new Query();
queryBuildRangeProj
= query.addDataSource(tablenum(CustTable)).addRange(fieldnum(CustTable,AccountNum)); // query
build for the form to display
queryBuildRangeProj.value(_accountNum);
// Criteria for the form
CustTable_ds.query(query);
// execution of the query
break;
}
}
super();
//datasource
initialization on the form based on the criteria
}
7.
In the class declaration of the form
public
class FormRun extends ObjectRun
{
SysLookupMultiSelectCtrl msCtrl;
AccountNum
_accountNum ;
}
8.
Tuesday, July 9, 2013
Number Sequence in Dynamic AX (for Form level)
1. Create EDT
2. Use that EDT in the Table
where it is required
3. Select the Class
module which you going to implement this Number seq.
//Consider if we want for HRM then “NumberSeqModuleHRM” class is the target.
//Add below code in the loadModule()
protected void loadModule()
{
NumberSeqDatatype datatype
= NumberSeqDatatype::construct();
//Added by Alfasith
datatype.parmDatatypeId(extendedtypenum(customerID));
//your EDT
//your EDT
datatype.parmReferenceLabel(literalstr("RES-customerID"));
//Your label
//Your label
datatype.parmReferenceHelp(literalstr("RES-customerID"));
datatype.parmWizardIsContinuous(true);
datatype.parmWizardIsManual(NoYes::No);
datatype.parmWizardIsChangeDownAllowed(NoYes::No);
datatype.parmWizardIsChangeUpAllowed(NoYes::No);
datatype.parmWizardLowest(1);
datatype.parmWizardHighest(99999999);
datatype.parmSortField(15);
//(This 15 is the next number that already in that default list)
//(This 15 is the next number that already in that default list)
datatype.addParameterType(NumberSeqParameterType::DataArea,
true, false);
this.create(datatype);
//code
end
}
4. Select the concern table. Create new methods as below
Here we take HRMParameters table
// table on which that number seq is going to generate.
// table on which that number seq is going to generate.
static client
server NumberSequenceReference
customer()
{
return NumberSeqReference::findReference(extendedtypenum(customerID));//Your EDT name
}
5. Create a new job with
the following code and run it:
static void NumberSeqLoadAll(Args _args)
{
NumberSeqApplicationModule::loadAll();
}
6. ( Control + W )
Select Organization administration-> Number Sequence-> Number
Sequence
Select the module //here we select Human Resources
Select the EDT you created //Surly that EDT you created will be
appear here.
Click GENERATE
7. Create a new job with
the following code and run it:
static void
NetvendNumberSeq(Args _args)
{
NumberSeq numberSeq;
StudentID num;
;
numberSeq = NumberSeq::newGetNum(VendParameters::student());
num =
numberSeq.num();
info(num);
}
8. Select the Form on
which that table is required.
Drop the table in to that form Data Source.
8(a). ClassDeclaration. Write the below code.
public class
FormRun extends ObjectRun
{
NumberSeqFormHandler
numberSeqFormHandler;
}
/*************************************************************/
8(b). Create new method
NumberSeqFormHandler numberSeqFormHandler()
{
if (!numberSeqFormHandler)
{
numberSeqFormHandler =
NumberSeqFormHandler::newForm(NetRMSParameters::customer().NumberSequenceId,
element,
Table2_ds,
fieldNum(Table2, customerID)
);
}
return numberSeqFormHandler;
}
/***********************************************************/
8(c). Override the datasource methods of that table with following
method in that form.
public void
delete()
{
;
element.numberSeqFormHandler().formMethodDataSourceDelete();
super();
}
/***********************************************************/
public void
write()
{
super();
element.numberSeqFormHandler().formMethodDataSourceWrite();
}
/***********************************************************/
public void
create(boolean _append = false)
{
;
super(_append);
element.numberSeqFormHandler().formMethodDataSourceCreate();
}
/***********************************************************/
Passing parameter between forms and Create reports using Multi select lookup
1.Create formA like
Note : FormA contains multiple select lookup so it has
features of getting the multiple Account Number;
Main class is modified as below in the FormA
public class
FormRun extends ObjectRun
{
SysLookupMultiSelectCtrl msCtrl;
}
/***************************************************/
//in the init method of FormA.
public void
init()
{
super();
// AccountNum - Name of control on which you want a lookup.
// CustQry - Query to get the lookup data of that required table
msCtrl =
SysLookupMultiSelectCtrl::construct(element, AccountNum, querystr(CustQry));
}
/***************************************************************/
//in the button clicked() in FormA.
void clicked()
{
// Args class is usually used in Axapta for passing
parameters between forms
Args args;
FormRun formRun;
container contain;
str
containstr;
;
args = new args();
// Our values which we want to pass to FormB
// If we want pass just simple string we can use 'parm'
method of 'Args' class
contain =
[AccountNum.valueStr()];
containstr = con2Str(contain);
args.parm(containstr);
// Run FormB
args.name(formstr(CustomerDetails));
formRun =
classFactory.formRunClass(Args);
formRun.init();
formrun.run();
formrun.wait();
super();
}
/*******************************************************************/
2.Create FormB as like this
On clicking of the above FormA “Clickhere” that concern AccountNum
details will be depicted in grid
//in the FormB Class declaration
public class
FormRun extends ObjectRun
{
container contain;
str CompanyId;
}
/*************************************************************************/
/ in the init() of that fornB
public void
init()
{
str tmp;
;
super();
// Check for passed arguments
if( element.args() )
{
contain = str2con(element.args().parm());
//Now receive the container multiple value with separater
as ";" to replace with ","
AccountNumb.text(strReplace(strFmt("%1",conPeek(contain,1)),';',','));
}
}
/**********************************************************/
In the Data source of the FormB drop the CustTable and in
the executeQuerry() of that datasource
//This makes the grid to reflect with reference to the
StringEdit that we added as the range to the grid.
public void
executeQuery()
{
this.query().dataSourceNo(1).addRange(fieldNum(CustTable,AccountNum)).value(AccountNumb.valueStr());
super();
}
/***********************************************************/
3.Onclicking of “Cust report Generator” that concern report
will be generated like this.
//here you find the change In the image that is because of
the company image.
Subscribe to:
Posts (Atom)
SQL code to upate one Legal entity banner to all the legal entity in D365
Hi, update companyimage set companyimage.Image = companyimageA.Image from ( select Image from companyimage where dataAreaid = 'USF...
-
Hi, AccountingDistribution ( accounting distribution 7452 ) AccountingDistributionEventTmp ( accounting distribution 100001 ) Accountin...
-
Hi, Create a EDT name it Gender then in properties enumType : //select the enum name Use the below code and enjoy. static v...