Running a report from a function

kwbburmeister
Member Posts: 15
Hello everyone,
I need some help running a report the way I want it to. I created a form, from which I want to run a report. In this form, I'm setting filters based on an option-field. Now I want to run a report with the option selected in the form.
The form filters the Sales Invoice Header. E.g. the user selects Netherlands from my option field, a function is setting filters on the country, the VAT Code and some other fields. My report creates a virtual invoice, in which I want to control the invoice receiver based on the option selected in the form. What I did: In my report I created a function with a rec-var and an option-var, which writes the local var from the function into a global variable for my report, in my form I'm calling the function with the filtered rec and the option selected. Now my problem is, that I don't know how to run the report after calling the function. I think I have to run in directly from my function, but how can I do this?
This is how my function within the report looks like now:
InvRec := InvAdress;
//InvRec is the global option-var, InvAdress is the local option-var
REPORT.RUNMODAL(77239,TRUE,TRUE,InvoiceHeaders);
//InvoiceHeaders is the local Rec-var
Thank you very much for your help!
I need some help running a report the way I want it to. I created a form, from which I want to run a report. In this form, I'm setting filters based on an option-field. Now I want to run a report with the option selected in the form.
The form filters the Sales Invoice Header. E.g. the user selects Netherlands from my option field, a function is setting filters on the country, the VAT Code and some other fields. My report creates a virtual invoice, in which I want to control the invoice receiver based on the option selected in the form. What I did: In my report I created a function with a rec-var and an option-var, which writes the local var from the function into a global variable for my report, in my form I'm calling the function with the filtered rec and the option selected. Now my problem is, that I don't know how to run the report after calling the function. I think I have to run in directly from my function, but how can I do this?
This is how my function within the report looks like now:
InvRec := InvAdress;
//InvRec is the global option-var, InvAdress is the local option-var
REPORT.RUNMODAL(77239,TRUE,TRUE,InvoiceHeaders);
//InvoiceHeaders is the local Rec-var
Thank you very much for your help!
0
Comments
-
see if you want to assign filter to DataItem(in your report) from the form then check "Voucher Printing Report" how Document no. passing and if you want to set any other filter(Parameter) based on calling form then create a function in report and setparameter to this function from form and use these parameter value to your filter.
for more detail you can search for this topic in forum....0 -
kwbburmeister wrote:What I did: In my report I created a function with a rec-var and an option-var, which writes the local var from the function into a global variable for my report, in my form I'm calling the function with the filtered rec and the option selected. Now my problem is, that I don't know how to run the report after calling the function.
repTest.Def(Param1, Param2); // Function Def to pass the 2 parameters over to the report repTest.RUNMODAL;
Is that what you're looking for?
Sascha0 -
I got closer to solving my problem. But I forgot to mention one thing:
In my form I created a button, which - pushed - sets the selected Lines on marked (SETSELECTIONFILTER). With the last answer on my post I get the correct option in my report. When I call my function with the rec-variable, the report still shows data for all lines (my report is based on the "Sales Invoice Header" table).
I'm not getting the clue how to filter the DataItem in my report to only the marked lines from my function!
Thanks in advance!0 -
For this effect you need a function in your report which accepts a record variable by reference. Call this function with your "selected" record variable before you run the report. Inside the function you assign the variable with COPY to a global variable in your report which will be used as filter for your corepsonding DataItem. Instead of a normal reference between records the function COPY also assigns marks. Check the help also.0
-
I use this kind of code
(rep is report,
NewRec is record same as Form data source):
CLEAR(rep);
CurrForm.SETSELECTIONFILTER(NewREC);
NewREC.MARKEDONLY(TRUE);
rep.SETTABLEVIEW(NewREC);
rep.RUNMODAL;
Wo.MARKEDONLY(TRUE);
Rep.SETTABLEVIEW(Wo);
Rep.RUNMODAL;0 -
Mistiped (double paste), correct is:
use this kind of code
(rep is report,
NewRec is record same as Form data source):
CLEAR(rep);
CurrForm.SETSELECTIONFILTER(NewREC);
NewREC.MARKEDONLY(TRUE);
rep.SETTABLEVIEW(NewREC);
rep.RUNMODAL;0 -
Send the Rec Var as a parameter in function that you are using with SETSELECTIONFILTER and use this rec var in report.
another way you can.....ReportVar.SETTABLEVIEW(RecVar of SETSELECTIONFILTER);
according to your requirment i recommended you to use second way.0 -
Thank you all very much! The SETTABLEVIEW-Function did it for me. I changed my function to only take the option.
Now my code in the form looks like (the lines are already marked at this point):
CLEAR(Rep);
Rep.GetInvAdress(InvoiceFilter);
Rep.SETTABLEVIEW(Rec);
Rep.RUNMODAL;
The function in the report:
GlobOptionVar := LocOptionVar;
And it works perfectly!!
Thanks again!0 -
Just a somewhat off topic remark:
Do not use MARKEDONLY(TRUE) in connection with SETSELECTIONFILTER. SetSelectionFilter sets MarkedOnly(True) *IF* it is using marks. It is not using marks if either all or no records are selected. If all records are selected, SetSelectionFilter is a NOP, if none is selected, SetSelectionFilter is equivalent to SetRecordFilter.0 -
I kinda have to do the same thing. But i dont understand what most of you guyz are talking about?
Is there any tutorial that shows how to do it or is there a step by step guide as to how I can do this. I am sorta a newbie at NAV thats why I am sorta lost...0 -
-
nverma wrote:I am sorta a newbie at NAV thats why I am sorta lost...
There's this thing called the "C/SIDE Reference Guide", it's in the Classic client under the help menu. Open it, go to the search page and type in keywords that you want to know more about. There are tons of examples and sample code in there. Go to the online help system, there are tons of walkthroughs and tutorials in there.0 -
Being honest, I have read the guide like so many times. For SETSELECTIONFILTER, all it says is: "Notes the records that the user has selected on the form, marks those records in the table specified, and sets the filter to "marked only"."
What I want to know is where does it save this information?? How can I retrieve this info?
Its not very detailed, I feel. Maybe thats just the newbie aspect of me talkign who doesnt know that much.0 -
I did a quick search on SETSELECTIONFILTER here on Mibuso and got back 79 results. A quick scan of some of those gave me plenty of topics where there are code examples.
I also did a quick google search and got back almost 3000 results on "SETSELECTIONFILTER Navision".
Surely there is something you can use in there.
These forums are not intended to provide a full explanation of an entire concept. You need to do some of the legwork yourself, and come with specific questions.0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions