Passing parameter from a form to a report

Hi

I’m trying to print a service document (own development) from the Service order form (SMAServiceOrderTable) The value I’m trying to get across is the Service order id (ServiceOrderID)

in the clicked method on the button in the form I have (the button is a MenuItemButton)

void clicked()
{
Args args = new Args();
super();

args.parm(SMAServiceOrderTable.ServiceOrderId);
args.caller(element);
}

and on the init() on the report i have this:

public void init()
{
;
super();

GetParm = element.args().parm();
ParmCaller = element.args().caller();
}

But the GetParm is empty altough the caller is recognised as the SMAServiceOrderTable

can anyone give me hint on what is wrong?

Thanks!

Ok, I believe that I see the problem there. You don’t need to override the clicked method on the form at all, as the caller will be populated automatically for you. What you’ll need to do is find the command button in the AOT, right click->properties and set the data source to the form level data source that you want to feed into it. Hope that helps. :3

I’m not sure I understand, first it is not a command button but a MenuItemButton.

Second I’m standing on the form(SMAServiceOrderTable), clicking the the menuItembutton should open a print report form (standard) and pass the service order ID to the Query

My first step was to try to get the SO ID over to the reprot, this is were by variable “GetParm” is empty…

secondly I need to override the query to set the query paramater to the SO ID. but thats a diffrent question (which I think I know how to do…)

Can you elaborate some more on how to pass the parmaters between to objects (form to report)

Thanks!!

just for debugging I have a Info() statement at the end of the init() on the report,

Info(GetParm) but this is empty as well…any clue?

Ahh, I see what you’re doing now. Ok, what you’ll want to do here is go to the menu item that is being referenced on the menuItemButton and take a look at it’s properties. Here, you can set what type and what value of parameters it should be handing to the report. The fields in the property menu you’ll be concerned with are Parameters, EnumTypeParamater and EnumParameter.

Hi, Buddy…

On form , MenuItemButton properties, set datasource as your table.

On report > init method,

Create an object of ur table(say ABC) and put

if(element.args().dataset() == tableNum())

{

ABC = element.args().record();

}

so it will initialise the ABC with the record of the selected record on the form.

Now , you can use values from ABC as u want…

Hope, it helps…

[Y]

I figured out a sligtly different solution that works.

On the Button Clicked method:

void clicked()
{

Args args = new args();
ReportRun reportRun;
;

args.parm(SMAServiceOrderTable.ServiceOrderId);

args.name(reportstr(GAB_ServiceOrder_NO));
reportRun = classFactory.reportRunClass(args);
reportRun.init();
reportrun.run();

super();
}

And then on the init method on the report;

public void init()
{
;
try
{
if(element.args().parm())
{
this.query().dataSourceTable(tablenum(SMAServiceOrderTable))
.addRange(fieldnum(SMAServiceOrderTable, ServiceOrderID)).value(element.args().parm());

this.query().userUpdate(false);
this.query().interactive(false);
super();
}
}

catch(exception::Error)
{
info(“Error in init method”);
}

}

Hi,guy, you can just go ahead with your original idea like this:

Let’s see what you have done:

  1. You’ve defined the Args at the Form.

  2. You get the args from the Report.

See what you’ve missed? Yes, you didn’t transfer the parameter from the Form to the Report

How to make it:

  1. Define the parameter you want to transfer at menuitem (Property of the menuitem).

  2. Assign value to the paramter at the Click(): this.menufunction().parameters(SMAServiceOrderTable.ServiceOrderID). This will transfer the value to the menuItem where you can access by args.parm().

Hope it helps.

Its Really Good Code

…and how it would work with multiple records selected?

Thanks you for your help!

Could you find a solution for multiple records?

Is there a solution for multiple parameters?