1
   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

4
  • You called your function saveModel, not saveModal. This is a simple typo, could happen to anyone.
    – sfdcfox
    Commented Aug 18, 2019 at 14:08
  • @sfdcfox Thanks. Can you help me how to refresh the model after clicking saveandnew
    – Mentee
    Commented Aug 18, 2019 at 23:35
  • @sfdcfox I tried to use eval("$A.get('e.force:refreshView').fire();"); it did not work :(
    – Mentee
    Commented Aug 19, 2019 at 6:43
  • You can't use eval in LWC, as far as I'm aware. We would need to see the relevant code to help you with your new problem. Please ask a new question, as it is generally considered bad form to change a question substantially, especially after answers have already been given.
    – sfdcfox
    Commented Aug 19, 2019 at 6:46

1 Answer 1

1

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

1
  • yes it is working now. can you help me with the other question please
    – Mentee
    Commented Aug 18, 2019 at 23:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .