i create lwc component and i need prewiew files from ContentVersion. for this i create:


public with sharing class SendInvoiceService {
public static List<ContentVersion> getPreview(id contentVId){
    return [SELECT Id, Title, FileExtension, ContentDocumentId From ContentVersion where id=:contentVId];
} }


<lightning-card title="Send Invoice" >
<a onclick={navigateToFiles}>Navigate To Files</a>


import { LightningElement, api, wire } from 'lwc';
import getInvoice from '@salesforce/apex/SendInvoiceService.getInvoice';
import NAME_FIELD from '@salesforce/schema/SendInvoice__c.FirstName__c';
import SUBJECT_FIELD from '@salesforce/schema/SendInvoice__c.Subject__c';
import EMAIL_FIELD from '@salesforce/schema/SendInvoice__c.Email__c';
import BODY_FIELD from '@salesforce/schema/SendInvoice__c.Body__c';
import { getSObjectValue } from '@salesforce/apex';
import { refreshApex } from '@salesforce/apex';

// importing navigation service
import { NavigationMixin } from 'lightning/navigation';

export default class sendInvoiceLWC extends NavigationMixin(LightningElement) {
@api recordId;
@api wiredContact;
@api realFormData;
@api InvoiceObj;
@wire(getInvoice, { oppId:'$recordId' }) fetchedInvoice( resp){
    this.wiredContact = resp;
    this.realFormData = this.wiredContact.data;

get Subject() {
    return this.InvoiceObj.data?getSObjectValue(this.InvoiceObj.data,SUBJECT_FIELD,NAME_FIELD,EMAIL_FIELD,BODY_FIELD):'nothing';
  navigateToFiles() {
      type: 'standard__namedPage',
      attributes: {
          pageName: 'filePreview'
      state : {

when i click on my button i have error:

Unfortunately, there was a problem. Please try again. If the problem continues, get in touch with your administrator with the error ID shown here and any other related details. Error ID: 851152862-1216293 (-1143180353) Maybe i need to get import from my getPreview? and upgrate method when i use navigateToFiles?

1 Answer 1


You have to actually pass the content document id( 15 digit or 18 digit ) as selectedRecordId not 'ContentDocumentId' as a string.

You must log in to answer this question.