1

I have a custom LWC under the "View Writeup" Tab in my Lightning Record Page. I would like to fire an Event in the LWC anytime the Record Page Tab is selected.

I tried including the event under a renderedCallback however this only fires on the initial selection of the tab. I would like the event to also fire if a User selects another Record Page Tab and then goes back to the "View WriteUp" Tab

enter image description here

JS

import {LightningElement, api} from 'lwc';
import getFiles from '@salesforce/apex/PreviewRelatedPdf_Helper.GetFile';

export default class PreviewRelatedPdf extends LightningElement {
  @api recordId;
  @api titleSearch;
  @api lookupApiName;

  renderedCallback() {
    this.handleGetFiles();
  }

  showFile=true;
  documentURL; 
  handleGetFiles(){
    getFiles({
      recordId: this.recordId,
      titleSearch: this.titleSearch,
      lookupApiName: this.lookupApiName
    })
    .then(result =>{
      if(result){
        this.showFile=true;
        this.documentURL = '/sfc/servlet.shepherd/document/download/' + result;
      }else{
        this.showFile=false;
      }
    })
    .catch(error =>{
        this.showFile=false;
        console.log('Error = ' + error);
    })
  } 
  
}
2
  • Wondering if you can use some dynamic interactions for this...?
    – Phil W
    Commented Dec 28, 2022 at 17:40
  • I am using this LWC on a Record Page. I cannot add an Event to the meta.xml as "The 'event' tag isn't supported for lightning__RecordPage" Commented Dec 28, 2022 at 19:14

0

You must log in to answer this question.