Advertisements

Controlling User wise Report Print & Save As… Permission

 

It is always asked from several users to have a control on Printing of reports from Preview.

Normally you have two options to print the Report in Navision.

  • From Request Page

PrintPreview1

  • From Print Preview

PrintPreview2

If you check document Reports you will notice that you don’t have option to Print the Report from Preview, but you can print from Request Page.

Why it doesn’t allow in such Reports?

It is because these report uses statement like:

IF NOT CurrReport.PREVIEW THEN

If the C/AL code for the report uses the PREVIEW function to disable printing from the preview, then users cannot change the display mode to print layout.

Using these option I have tried to disable Printing of Report from Request Page and Print Preview.

PrintPreview3

 

Add a Boolean type Field in User Setup Table & Page as shown above.

Now the report which we want to restrict from printing we will add piece of code.

Although there are other ways to do this but to keep it simple I have followed this approach. Once you are ok with logic you can implement the same in your way, in fact more better way than this sample demo.

PrintPreview4

If I run the report by setting Allow Report Printing to FALSE, it will not show me the Print & Save as Option on Preview.

PrintPreview5

Also if I Try to Print or Save As… from Request Page it will Flag me an error as above.

So now you know the logic behind it, what you are waiting for. Give your user to control the Printing & Save As… option.

Now in last Cumulative Updates also Microsoft added option to control this,  but it is at Service Level, if you want to control at user Level this is one option, wait for any further Cumulative Update in which Microsoft may add this capability or explore and find any other option and share with others.

That’s all for this post. I will come up with more details in my upcoming posts.

Till then keep exploring & learning.

 

 

Advertisements

Usage of RUNREQUESTPAGE, EXECUTE, SAVEAS and PRINT function of Reports Object

Today we will discuss usage of RUNREQUESTPAGE, EXECUTE, SAVEAS and PRINT function of Report Object.

You will be using RUNREQUESTPAGE function to run the request page of desired Report.

We will save the value of Parameters in Table for further use. For this we will require to create a table with below structure let name it as Report Request Parameters.

Create a table called Report Request Parameters that has the following fields.

Field Name Data Type Length
ReportId Integer
UserId Code 100
Parameters BLOB

ReportParameter-1

Then we will use these value with

EXECUTE – To preview the report.

SAVEAS – To save it as pdf file.

PRINT – To print the Report.

To continue with our demo we will require to create a codeunit, let’s name it as Using Report Functions.

We will add the following variables in the C/AL Globals window.

Variable name DataType Subtype Length
ReportParameters Record Report Request Parameters
XmlParameters Text
OStream OutStream
IStream InStream
CurrentUser Code 100
Content File
TempFileName Text

ReportParameter-2

Now we will add the following code to the OnRun trigger of the codeunit.

We will be taking Report 206 as an example for this demo.

ReportParameter-3

You can copy below code for your demo.

// Use the REPORT.RUNREQUESTPAGE function to run the request page to get report parameters

XmlParameters := REPORT.RUNREQUESTPAGE(206);

CurrentUser := USERID;

// Save the request page parameters to the database table

WITH ReportParameters DO BEGIN

// Cleanup

     IF GET(206,CurrentUser) THEN

DELETE;

SETAUTOCALCFIELDS(Parameters);

ReportId := 206;

UserId := CurrentUser;

Parameters.CREATEOUTSTREAM(OStream,TEXTENCODING::UTF8);

MESSAGE(XmlParameters);

OStream.WRITETEXT(XmlParameters);

INSERT;

END;

CLEAR(ReportParameters);

XmlParameters := ”;

// Read the request page parameters from the database table

WITH ReportParameters DO BEGIN

SETAUTOCALCFIELDS(Parameters);

GET(206,CurrentUser);

Parameters.CREATEINSTREAM(IStream,TEXTENCODING::UTF8);

IStream.READTEXT(XmlParameters);

END;

// Use the REPORT.SAVEAS function to save the report as a PDF file

Content.CREATE(‘TestFile.pdf’);

Content.CREATEOUTSTREAM(OStream);

REPORT.SAVEAS(206,XmlParameters,REPORTFORMAT::Pdf,OStream);

Content.CLOSE;

// Use the REPORT.EXECUTE function to preview the report

REPORT.EXECUTE(206,XmlParameters);

// Use the REPORT.Print function to print the report

REPORT.PRINT(206,XmlParameters);

We are done, definitely this will help you doing some useful stuffs in your projects.

Run the Codeunit and see the output. You will get three output

a) Report Output will be saved as pdf, you can specify your custom path to save the file to specified location.

b) Report Print Preview

c) Report will be send for Printing

The New Report Scheduling feature for end users running reports in Microsoft Dynamics Navision 2015


The new Report Scheduling feature for end users running reports:

  • End user can schedule reports for later execution.
  • User can get to his next task quicker.
  • User has an inbox part for viewing the scheduled reports.

 A. Setting up the job queue to run a report

My Customer needs to run a number of long running reports and does not want to wait for them to complete.

The scenario is simplified because a typical customer setup would involve setting up a NAS instance to process the reports.

* Open the Job Queues page.

ReportSchedule-1

* On the Home tab, in the New group, choose New to set up a new job queue

ReportSchedule-2

* In the Code field, type Reports.

* Fill in the Description field My Report Schedule.

* Leave the Job Queue Category Filter field blank.

* On the Home tab, in the Process group, choose Start Job Queue.

* Close the Job Queue Card

ReportSchedule-3

A job queue with no filter runs the reports.

In many customer installations, the reports will be picked up by the DEFAULT job queue


B. Adding the Report Inbox to the Role Center

My Customer wants easy access to the reports that he has scheduled, so he adds the Report Inbox part to the Role Center page.

* To open the Role Center page that you want to customize, in the navigation pane, choose the Home button, then choose the Role Center menu item.

* On the Application menu , choose Customize, and then Customize This Page.

* In the Available Parts pane, select Report Inbox, and then choose the Add button.

* To move the Report Inbox part to top of the second column in the Role Center layout pane, select it and then use the Move buttons.

* (Optional) To add the My Job Queue to the Role Center, in the Available Parts pane, select My Job Queue, and then choose the Add button.

* (Optional) To move the My Job Queue part below the Report Inbox in the Role Center layout pane, select it and then use the Move buttons.

ReportSchedule-4

ReportSchedule-5

* Verify that the Report Inbox appears in the Role Center.

ReportSchedule-6


C.Scheduling a report and viewing the result

* On the Role Center, on the Report tab, choose Customer Order – Summary.

* On the report request window, choose the Print button, and then choose Schedule

ReportSchedule-7

* In the Schedule a Report window that appears, in the Description field type a different text.

* In the Report Output Type field, select the down arrow, and choose PDF.

* Choose the OK button.

ReportSchedule-8

* Go to the Report Inbox on the Role Center and show that the report appears when it is finished running.

* To view the report, select it in the Report Inbox, and then choose Show.

ReportSchedule-9


D. When a scheduled report fails

* Open the Role Center.

* On the Application menu , choose Customize, and then Customize This Page.

* In the Available Parts pane, select My Job Queue, and then choose the Add button.

* To move the My Job Queue part below the Report Inbox in the Role Center layout pane, select it and then use the Move buttons

* In the Role Center, go to the My Job Queue part.

We have already done above step in above steps. Let’s continue with next step. If not already done follow the steps as defined above.

* On the Role Center, on the Reports tab, choose Price List.

* In the Sales Type field select Customer.

* To schedule the report to run later, choose the Print button, then select Schedule.

* In the Schedule a Report window, leave the default values in fields and choose the OK button.

ReportSchedule-10

* When the error shows up in the My Job Queue part, select the error, and then choose Show Error.

* Read the error message, and then choose the OK button to close it.

ReportSchedule-11

* Open the Job Queue Log Entries page.

* Filter the list to display entries whose Status is Error.

* To view the error message, point to the Error message field for the entry, or, select the entry, and then on the Home tab, choose Show Error Message.

* Return to the Role Center, and then run the Price List report again.

* On the report request window, set the Sales Type field to All Customers, choose Print, and then choose Schedule.

* In the Schedule a Report window, leave the default values in fields and choose the OK button.

* In the Report Inbox on the Role Center, view the completed report.

ReportSchedule-12


Important

Most of the contents you find in this blog will be either inherited from MSDN or Navision Developer IT Pro Help. Some places images are also directly taken from these sites. Purpose is simple to try those stuffs and re-produce adding few things as per my understanding to make easy understanding for others and quick reference.

Here nothing under my own brand or authorship of the content. At any point of time we are just promoting Microsoft stuffs nothing personnel with same.

Hope stuffs used here will not violate any copyright agreement with them. In case by mistake or in-intestinally it happens and the Microsoft feels these should not be used Microsoft have full right to inform me about same and will be glad to take down any such content which may be violating the norms.

Purpose is to promote Navision and share with community.

FB Profile

Like FB Page

%d bloggers like this: