Hi,
To highlight the row in axapta report based on specific value just add the following code in the execution section of section group.
public void executeSection()
{
int usecolor
;
usecolor=WinApi::RGB2int(255,0,0);
if(inventTable.itemprice>5)
{
this.foregroundColor(usecolor);
}
else
{
this.foregroundColor(white);
}
super();
}
this will highlight all the record where item greater then 5.
I hope it works .
Regards,
Tuesday, 8 November 2011
Friday, 28 October 2011
How to pass parameters from Form to form
Hi,
Sometimes we want to open a form from another form with the selected record . For this we need to pass the parameters from form A to form B . This could be achieved by using args class by overriding the click method of button on form A.
In this example we will use two forms form A is salesLine form and form B is inventenquiry form. when the user will click on the button on form A it will open form B filtering the record according the form A value.lets start
void clicked()
{
//super();
Args args=new Args();
Itemid itemid;
FormRun formRun;
;
args.name(formstr(InventEnquiry)); // invent enquiry is the form B
args.parm(salesLine.ItemId);// passing the item id from Form A
formRun = classFactory.formRunClass(args); /// passing the args class
formRun.init();
formRun.run();
formRun.wait();
}
3.Now override the init method of the form B data source inventTable
public void init()
{
super();
if(element.args().parm())
{
this.query().dataSourceName('InventTable').addRange(fieldnum(InventTable,ItemId)).value(element.args().parm());
this.query().userUpdate(false);
this.query().interactive(false);
}
}
Hope it helps
cheers,
Sometimes we want to open a form from another form with the selected record . For this we need to pass the parameters from form A to form B . This could be achieved by using args class by overriding the click method of button on form A.
In this example we will use two forms form A is salesLine form and form B is inventenquiry form. when the user will click on the button on form A it will open form B filtering the record according the form A value.lets start
- Put a button on form A and override its click method
- write the following code
void clicked()
{
//super();
Args args=new Args();
Itemid itemid;
FormRun formRun;
;
args.name(formstr(InventEnquiry)); // invent enquiry is the form B
args.parm(salesLine.ItemId);// passing the item id from Form A
formRun = classFactory.formRunClass(args); /// passing the args class
formRun.init();
formRun.run();
formRun.wait();
}
3.Now override the init method of the form B data source inventTable
public void init()
{
super();
if(element.args().parm())
{
this.query().dataSourceName('InventTable').addRange(fieldnum(InventTable,ItemId)).value(element.args().parm());
this.query().userUpdate(false);
this.query().interactive(false);
}
}
Hope it helps
cheers,
Friday, 14 October 2011
How to save the report in PDF format on selected location
Hi,
To run and save the axapta report in PDF format on your hard drive just override the init() method of your report with the following code.
public void init()
{
Regards,
To run and save the axapta report in PDF format on your hard drive just override the init() method of your report with the following code.
public void init()
{
super();
element.printJobSettings.setTarget(PrintMedium::File); // print format is on file
element.printJobSettings.preferredTarget(PrintMedium::File);
element.printJobSettings.format(PrintFormat::PDF);
element.printJobSettings.preferredFileFormat(PrintFormat::PDF); //file extension is pdf
element.printJobSettings.fileName("c:\\temp\\test-invoice.pdf"); // file location and name
element.printJobSettings().warnIfFileExists(false); // dont show the option to overwrite report file
element.printJobSettings().allPages(false); // dont print all pages of report
element.printJobSettings().from(2); // print from page 2
element.printJobSettings().to(5); //print to page 5
element.query().interactive(false); // disable all dialogue
element.report().interactive(false);
}Regards,
Wednesday, 12 October 2011
How to pass parameters from Form to Class
Hi,
To pass the parameters from form to class is straightforward.
1.Create a class yourClass
class yourClass { }
2. override the new method
{
PurchID purchId;
Args args=new Args();
YourClass yourClass;
;
purchId=args.parm(purchTable.purchid);
yourClass=new YourClass(purchid);
}
Save and Compile
now when u will hit the button on purchTable form it will return the current purchid of the data source . I hope it will help
Cheers,
To pass the parameters from form to class is straightforward.
1.Create a class yourClass
class yourClass { }
2. override the new method
void new(PurchID purchid)
{
;
info(Itemid);
}
---------- Class Completed
Go to form purchTable
1. Add a button
2. override the click method of the button with following code
void clicked() {
PurchID purchId;
Args args=new Args();
YourClass yourClass;
;
purchId=args.parm(purchTable.purchid);
yourClass=new YourClass(purchid);
}
Save and Compile
now when u will hit the button on purchTable form it will return the current purchid of the data source . I hope it will help
Cheers,
Monday, 12 September 2011
How to insert a Page footer on the last page in Axapta report
Hi,
Normally developers need the term and condition or other stuff to be displayed only on the last page .To insert the footer only on the last page of Axapta report do the following stes.
1. Declare a boolean variable (pageFooter) in report class declaration method .
public class ReportRun extends ObjectRun
{
boolean pageFooter;
}
2. Override the report fetch method with query
public boolean fetch()
{
boolean ret;
ret = super();
printPageFooter=false;
while(queryrun.next())
{
}
printPageFooter=true;
return true;
}
3. Override the executeSection method of footer
public void executeSection()
{
if(printPageFooter==true)
super();
}
and your done now when ever your will run a report only the last page will display the page footer.
Regards,
Normally developers need the term and condition or other stuff to be displayed only on the last page .To insert the footer only on the last page of Axapta report do the following stes.
1. Declare a boolean variable (pageFooter) in report class declaration method .
public class ReportRun extends ObjectRun
{
boolean pageFooter;
}
2. Override the report fetch method with query
public boolean fetch()
{
boolean ret;
ret = super();
printPageFooter=false;
while(queryrun.next())
{
}
printPageFooter=true;
return true;
}
3. Override the executeSection method of footer
public void executeSection()
{
if(printPageFooter==true)
super();
}
and your done now when ever your will run a report only the last page will display the page footer.
Regards,
Labels:
Axapta,
Dynamics AX Report,
page footer,
Reports
Location:
Romford, Greater London, UK
Sunday, 26 June 2011
how to write select statement with while Loop in X++
Using select statement with while loop is something which has to do on daily bases to get the multiple records from statement. To exercise this statement lets assume we have a Books table which contain more then one record which we want to see. Lets write a job in editor
Static Void getBooksRecord(Args args)
{
BookTable bookTable;
int records;
;
while select bookTable
{
info("--------------NEW RECORD--------------");
info (strfmt("BookId: %1", bookTable.BookId));
info (strfmt("Title: %1", bookTable.BookTitle));
info (strfmt("Author: %1", bookTable.Author));
info (strfmt("ISBN: %1", bookTable.ISBN));
records++;
}
info("------------------END-------------------");
info(strfmt("%1 records was selected", records));
}
// Executing this Job will result in the writing output to the Infolog. Note that only
the first records are shown in the Infolog window. When executing it yourself, you
can scroll down to see the other records at the end line
Static Void getBooksRecord(Args args)
{
BookTable bookTable;
int records;
;
while select bookTable
{
info("--------------NEW RECORD--------------");
info (strfmt("BookId: %1", bookTable.BookId));
info (strfmt("Title: %1", bookTable.BookTitle));
info (strfmt("Author: %1", bookTable.Author));
info (strfmt("ISBN: %1", bookTable.ISBN));
records++;
}
info("------------------END-------------------");
info(strfmt("%1 records was selected", records));
}
// Executing this Job will result in the writing output to the Infolog. Note that only
the first records are shown in the Infolog window. When executing it yourself, you
can scroll down to see the other records at the end line
Subscribe to:
Posts (Atom)