I have written a generic function which takes a variant as its parameter and a report ID. The idea is to be able to pass any type of record to the function such as Customer, Vendor, Item, Production Order etc... and then produce a report from it.
Function:
DoSomething(ReportID : Integer; SomeRec : Variant Value) {
REPORT.RUNMODAL(ReportID, FALSE, FALSE, SomeRec)
}
But this does not work? Navision just crashes and restarts. What's the best alternative without having to do multiple case/if statements to cast it back to a specific record type?
Comments
No wonder NAV crashes.
Could you explain why this function would be usefull?
|To-Increase|
I am trying to write a generic function to print a particular report to a default printer but also passing the correct record to the report. Is this possible?
I would be using this as a means of converting any Navision report to PDF and saving it to a directory.
rpt1.SETTABLEVIEW(rec1);
rpt1.RUNMODAL;
where in you declare
rpt1 as a variable of type report and subtype= reportid/report name of the report you want to run
and rec1 is the variable of type record
On the other hand, the current report-handlers should give enough possibilities for modification.
I created a print-to-pdf function with these tables.
Report selection and printer selection tables are the ones you need.
But for a generic function, I don't think with the objects NAV lets us use are sufficient.
|To-Increase|
Then, in report you can use RecordRef and FieldRef functions for the record, which table and primary key fields equals received parameters.
For most tables in NAV not more then 3 fields in Primary Key is used.
Follow my blog at http://x-dynamics.blogspot.com