Advanced Portal Designer Documentation
Index

Report Action

Report actions generate and serve Business Central reports through your portal, allowing users to download or view documents in various formats.

Overview

A Report action:

  • Executes a BC report
  • Outputs in configurable formats
  • Supports custom report layouts
  • Can download or display inline

When to Use Report Actions

Use Report actions for:

  • Invoice downloads
  • Order confirmations
  • Custom statements
  • Document generation
  • Print-ready output

Creating a Report Action

Step-by-Step

  1. Open the Advanced Portal Designer menu page (search for it in Tell Me) and click Actions
  2. Click New
  3. Enter the Web Action code
  4. Set Type to "Report"
  5. Select the Object No. (Report ID)
  6. Configure output format
  7. Configure destination
  8. Set layout (optional)
  9. Save the action

Configuration Options

Object No.

Select the report to execute:

  • Use lookup to browse available reports
  • Enter the report ID directly
  • Report must be published and accessible

Report Output Format

Choose the output format:

Format Description Extension
PDF Portable Document Format .pdf
Excel Microsoft Excel .xlsx
Word Microsoft Word .docx
XML XML Data .xml
HTML HTML Format .html

Destination

Choose how the report is delivered:

Destination Behavior
Download Browser downloads the file
Inline (html) Content displayed in page

Report Layout

Optionally specify a custom report layout:

  • Leave blank for default layout
  • Select from available custom layouts
  • Layout must be defined in BC

Passing Parameters

Report filters are configured on the action in BC, not by passing OData-style filters in the URL. Open the action card and navigate to the report's DataItems list. For each filter, choose a Filter Type:

Filter Type Behavior
Filter Static BC filter expression applied to the field
Parameter At runtime, APD reads the named URL parameter and applies it as a filter on this field
BCIdentity Filter the field to the user's BC Number (NAV Identification)
Company Filter the field to the user's company

To accept the URL parameter docno, add a Parameter filter on (for example) the Sales Invoice Header's No. field with Filter Value = docno, then call:

?action=INVOICE-PDF&docno=103001

Security filters always apply on top of these — users cannot see records outside their Security Setup, regardless of which URL parameter they pass.

Example: Invoice Download

Setup

  1. Create action "DOWNLOAD-INVOICE"
  2. Set Type to "Report"
  3. Select Standard Sales - Invoice report
  4. Set Output to "PDF"
  5. Set Destination to "Download"

URL

?action=DOWNLOAD-INVOICE&no=103001
<a href="?action=DOWNLOAD-INVOICE&no=<?field(Sales Invoice Header,No.)?>">
    Download Invoice PDF
</a>

Example: Statement Inline

Setup

  1. Create action "VIEW-STATEMENT"
  2. Set Type to "Report"
  3. Select your statement report
  4. Set Output to "HTML"
  5. Set Destination to "Inline (html)"

Usage

The report HTML renders directly in the page.

Report Layouts

Using Custom Layouts

  1. Create custom layout in BC (Report Layouts)
  2. Note the layout code
  3. In action, enter the layout code in Report Layout

Word vs RDLC Layouts

Layout Type Formats Supported
RDLC PDF, Excel, Word
Word Word, PDF
Excel Excel

Security Considerations

Data Access

Reports run with portal user context:

  • Apply appropriate security filters
  • Validate access to requested data
  • Consider what data the report exposes

Example: Customer-Specific

For per-user filtering, add a BCIdentity filter on the DataItem that contains the customer field — APD applies the current portal user's BC Number (NAV Identification) to that field automatically. You do not need to modify the report code itself. If you need finer control, you can also configure Security Filters on the underlying table (see Security Filters) — those are applied on top of any report filter you configure here.

Integration Patterns

Download Button

<button onclick="window.location.href='?action=DOWNLOAD-PDF&no=<?field(Document,No.)?>'">
    Download PDF
</button>
<button onclick="printReport()">Print</button>

<script>
function printReport() {
    var printWindow = window.open('?action=VIEW-REPORT-HTML&no=' + documentNo, '_blank');
    printWindow.print();
}
</script>

Email Attachment

Combine with codeunit action to:

  1. Generate report
  2. Attach to email
  3. Send via BC email

Multiple Documents

Batch Downloads

For multiple documents, consider:

  1. Generate individual PDFs
  2. Combine into ZIP
  3. Single download

Iteration

<?open("Sales Invoice Header")?>
<?loop("Sales Invoice Header",'-')?>
    <a href="?action=DOWNLOAD-INVOICE&docno=<?field("Sales Invoice Header","No.")?>">
        Invoice <?field("Sales Invoice Header","No.")?>
    </a><br>
<?endloop("Sales Invoice Header")?>
<?close("Sales Invoice Header")?>

(The example assumes the DOWNLOAD-INVOICE action has a Parameter-type filter on the report's No. field reading the docno URL parameter.)

Troubleshooting

Report Not Found

  • Verify report ID exists
  • Check report is published
  • Ensure proper permissions

Format Issues

  • Verify layout supports chosen format
  • Check for layout errors in BC
  • Test report in BC first

No Output

  • Check report has data
  • Verify filters aren't too restrictive
  • Test with simpler parameters

PDF Issues

  • Ensure RDLC layout available
  • Check for complex elements
  • Test in BC report viewer first

Performance

Large Reports

For large reports:

  • Consider pagination
  • Use background processing
  • Provide progress feedback

Caching

  • Reports are generated fresh each request
  • Consider caching for repeated requests
  • Implement smart caching strategies

Best Practices

Report Design

  • Design reports with portal use in mind
  • Include clear headers and footers
  • Make them printer-friendly

Security

  • Always validate user access
  • Filter data appropriately
  • Log report generation

User Experience

  • Show loading indicators
  • Handle errors gracefully
  • Provide format options when appropriate