Question

Overriding save function

Hi,

In contact section, on saving I am trying to get a popup message if there is a duplicate and do not save the record. Now, Record is getting saved if checkDuplicateEmail() returns true or false. 

Could you please correct the code?

Is there any other way to do it ?

save: function() {

                    if (this.checkDuplicateEmail() === false) {

                        return;

                    }else{

                        this.callParent(arguments);

                    }

                },

Thanks in Advance

Like 0

Like

2 comments

I guess this won't work, because checkDuplicateEmail() is asynchronous, you should use method asyncValidate()

asyncValidate: function(callback, scope) {
 this.callParent([function(response) {
  if (!response.success) {
   callback.call(scope || this, response);
  }
  else {
   this.checkDuplicateEmail(callback, scope || this);					
  }
 }, this]);
},
checkDuplicateEmail(callback, scope) {
//your ESQ
 esq.getEntityCollection(function (result) {
  if (yourCondition) {
   if (callback) {
	callback.call(scope, {
	 success: false,
	 message: "You cannot save, because..."
	});
   }
	}
  else {
   if (callback) {
	 callback.call(scope, {
	 success: true
	});
   }
  }
 }, this);
}

 

Dear Nagaraju,



In order to resolve the issue please use the example that was described above. 

If you have any further question, please contact technical support. 



Best regards,

Norton

 

Show all comments