I was trying to show a PDF file during a Flow Process we have created.

At the beginning I used the 'iframe' tag but that didn't answer our needs (The PDF viewer didn't appear correctly and we used an obsolete viewer to achieve that). After that, we tried using Salesforce's default PDF viewer using NavigationMixin which seems to work great (And use standard Salesforce) but when we start the flow over a tablet and get to the document display step, nothing happens.

We thought maybe the problem occurs because we are trying to achieve that from inside a flow, and tested the same thing over a record page and still got nothing over the tablet (or mobile phones). The native viewer does not appear nor is the file downloaded.

Salesforce documentation states the following: "In the Salesforce app, a single file downloads when the event is fired. If selectedRecordId is specified, that file downloads. If selectedRecordId isn’t specified, the first file in the recordIds list downloads. Depending on the device, a native preview of the file displays." (https://developer.salesforce.com/docs/component-library/documentation/en/lwc/lwc.use_open_files)

Are we missing something? The code is as following:


import renderBlobPdf from '@salesforce/apex/renderBlob.renderBlobPdf';
import { NavigationMixin,CurrentPageReference } from 'lightning/navigation';

export default class DisplayPDF extends NavigationMixin(LightningElement) {

    @api formId;
    @api sobjectId;
    @api contentVersionId;

    @track error;

    connectedCallback() {
        // this.init();

        renderBlobPdf({ FormId: this.formId, sObjectId: this.sobjectId })

                this.contentVersionId = result;

                // Naviagation Service to the show preview
                    type: 'standard__namedPage',
                    attributes: {
                        pageName: 'filePreview'
                    state : {
                        // assigning ContentDocumentId to show the preview of file
                        selectedRecordId: result
            .catch (error=>{
                console.log('Error:' + error.message); 

    handleButton() {

The 'renderBlobPDF' method returns a document's ID to display.


    <div class="slds-col slds-m-left_small">                        
 <lightning-button-icon onclick  ={handleButton}


<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
        <targetConfig targets="lightning__RecordPage"> 
            <property name="formId" label="Form ID" type="Integer"/>
            <property name="sobjectId" label="Object ID" type="String"/>
                <supportedFormFactor type="Small"/>
                <supportedFormFactor type="Large"/>
        <targetConfig targets="lightning__FlowScreen"> 
            <property name="formId" label="Form ID" type="Integer"/>
            <property name="sobjectId" label="Object ID" type="String"/>

To be clear, this works perfectly over a PC in a web browser but when using the same Flow over a tablet (that runs Android, if that matters) nothing happens.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.