[SalesForce] LWC function calls – Apex Method Imperatively

   import { LightningElement, track, api} from 'lwc';

   import saveRecord from '@salesforce/apex/Controller.saveRecord';



export default class CreateModel extends LightningElement {
  @track showModal=true; 
  flag = false;
  @api reqId;
 saveModal(){
    this.bShowModal = false
    saveGoalRecord({id: this.reqId})
          .then(result => { this.f = result })
          .catch(error => { this.error = error })
  }

saveNewModal() {
    alert("hisn");
    this.saveModal();    
    this.bShowModal = true;
}
closeModal() {  
    this.bShowModal = false;
}

}

saveModal method works but when I am trying to call the same function in saveNewModal() I get the below error. and also I am trying to refresh the page after the saveModal() call in saveNewModal(), no idea how to do it.
any inputs please?

enter image description here

Best Answer

As @sfdcfox commented, you defined saveModel but you are invoking this.saveModal();. You need to invoke this.saveModel();

Also you need to import saveGoalRecord method from Apex Controller as you are calling that metod imperatively in saveModel

Related Topic