Previewing a report programatically
Cem_Karaer
Member Posts: 281
Hi everyone,
Is not there a way to preview a report in the C/AL code. I designed a report that does not require any options or any filters or any sorting schema. I can print it directly without letting it show its request form but I cannot preview it. Just showing up a form with only buttons is a wierd, non-Navision-looking situation.
If there is no way to prevent this technically, what can I do as respects aesthetics.
Is not there a way to preview a report in the C/AL code. I designed a report that does not require any options or any filters or any sorting schema. I can print it directly without letting it show its request form but I cannot preview it. Just showing up a form with only buttons is a wierd, non-Navision-looking situation.
If there is no way to prevent this technically, what can I do as respects aesthetics.
Cem Karaer @ Pargesoft
Dynamics NAV Developer since 2005
Dynamics NAV Developer since 2005
0
Answers
-
As far as I know, there is no way to do that, except running it using request form
0 -
You can use key stroke macro. Search mibuso on how to.0
-
To do it simply, place this in Report - OnOpenForm() which you can access through the request form designer. Remember to change {v} for whatever it is in the language you are using. You can even get the language code off Navision and then do a CASE on the different languages you are dealing with. % in SENDKEYS means ALT {v} means lowercase 'v' which is the shortcut for preview in the English version. The button says 'Preview'. In the Peninsular Spanish version it's {p} because the button text is 'Vista preliminar'
WshShell is an Automation variable with subtype 'Windows Script Host Object Model' and object of WshShell. Thus, subtype is 'Windows Script Host Object Model'.WshShellCREATE(WshShell); WshShell.SendKeys('%{v}'); CLEAR(WshShell);
So, for Spanish and English, you can do this:CREATE(WshShell); IF CurrReport.LANGUAGE = 1034 THEN WshShell.SendKeys('%{p}') // Spanish ELSE WshShell.SendKeys('%{v}'); // English CLEAR(WshShell);
If you want to control the behavior of this, you can create a function that you can call before you run the report, so that if run default it shows the request form, otherwise it will hide it if you call the function. In this case, you have a global variable, say HideForm - Boolean, and you have a global function as so that does HideForm := TRUE;
The code in the Report - OnOpenForm() would then be:IF HideForm THEN BEGIN CREATE(WshShell); IF CurrReport.LANGUAGE = 1034 THEN WshShell.SendKeys('%{p}') // Spanish ELSE WshShell.SendKeys('%{v}'); // English CLEAR(WshShell); END;
Good luck.0 -
Thank you MTC! It works.Cem Karaer @ Pargesoft
Dynamics NAV Developer since 20050 -
And it is the smartest trick I have ever got about Navision :P (understandable if it is counted that I'm only one-yeared developer
) Cem Karaer @ Pargesoft
Dynamics NAV Developer since 20050
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.7K Microsoft Dynamics NAV
- 18.8K 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
- 327 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
