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;
    this.bShowModal = false
    saveGoalRecord({id: this.reqId})
          .then(result => { this.f = result })
          .catch(error => { this.error = error })

saveNewModal() {
    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

  • You called your function saveModel, not saveModal. This is a simple typo, could happen to anyone. – sfdcfox Aug 18 '19 at 14:08
  • @sfdcfox Thanks. Can you help me how to refresh the model after clicking saveandnew – Mentee Aug 18 '19 at 23:35
  • @sfdcfox I tried to use eval("$A.get('e.force:refreshView').fire();"); it did not work :( – Mentee Aug 19 '19 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 Aug 19 '19 at 6:46

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

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

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.