Loading

How to Open a PDF in the Salesforce Mobile App for Android and iOS

Veröffentlichungsdatum: May 22, 2026
Beschreibung

It is possible to open a PDF view in the Salesforce Mobile App for Android and iOS. The PDF displays as a thumbnail view with a download link that opens the full PDF in a separate browser window on the mobile device. There are best practices to follow and known limitations to be aware of.

Best Practices

Use the sforce.one.navigateToSObject() event call to open a PDF in the Salesforce Mobile App environment. This method is designed for use in the Salesforce for Android and iOS app context only. Do not hard-code URL values to open PDFs in the mobile app.

Note: The navigateToSObject() event call opens the PDF in a new browser window window on the mobile device. Rendering a PDF inside the app context is not supported — this is working as designed. Ensure your mobile browser is configured to allow pop-ups for seamless PDF rendering.

Lösung

Opening a Previously Uploaded PDF

If the PDF has already been uploaded to the Files tab in Salesforce, use its ContentDocument record ID as the parameter in the sforce.one.navigateToSObject() method call. The ContentDocument record ID starts with the prefix 069. To find the ID, open the Files tab in Salesforce desktop and copy the record ID from the URL.
Do not use the legacy Attachment record ID — navigateToSObject() does not open PDFs using Attachment IDs.

Navigating to a PDF Using a Visualforce Page

To open a PDF in the Salesforce Mobile App from a Visualforce page, call sforce.one.navigateToSObject() in a JavaScript block on the page, passing the ContentDocument record ID (starting with 069) as the argument. The Visualforce page uses a standard controller (e.g., Campaign) to provide the page context, and the JavaScript method call navigates the mobile app to the Files record view for the specified PDF.

Navigating to a PDF Using a Lightning Component

In a Lightning (Aura) component, use the lightning:navigation service's navigate() method with a pageReference of type standard__recordPage. Set the recordId attribute to the ContentDocument ID (starting with 069), the objectApiName attribute to ContentDocument, and the actionName attribute to view. Call event.preventDefault() before invoking navService.navigate(pageReference) to prevent default link behavior.

Opening Dynamically Generated PDFs

If you need to dynamically build and display a PDF file, generate and save the file server-side via the Apex controller, then navigate to the newly created ContentDocument record ID. Generating the PDF on the server side avoids content-type handling conflicts that can occur when using the mobile webview. Salesforce Support cannot assist with building dynamic PDF generation functionality, but can help troubleshoot specific errors encountered when rendering dynamically generated PDFs.

Nummer des Knowledge-Artikels

000384273

 
Laden
Salesforce Help | Article