Hello Community,
I have a requirement, when a user changes the DCM status manually validation should trigger. To achieve this I am using asynValidate function and the validation is working fine.
But the issue here is status is not restoring back automatically and also both Save and Cancel button is showing as a result when I am trying to create a record in the connected detail the validation is triggering again. I have to manually click on Cancel before I can do any changes in the details. Please refer the screenshot below.
Before validation:
After validation:
Is there anyway after validation it should reset back to Close like in the 1st image?
Thanks,
Sourav Kumar Samal
Like
Anastasiia Zhuravel,
I have resolved the issue. To acheive the desired output I have added a small line after the error message as follows:
MandatoryValidation: function(callback, scope){ var DCMstatus = this.get("MarketingPlansStatus").displayValue; if(DCMstatus === "Business Owner Review"){ // Some query callback.call(scope || this, { success: false, message: "Error message" }); this.reloadEntity(); }else{ callback.call(scope || this, { success: true }); } },
Note: If the asynValidate is being used in this.NewMode(), avoid adding this.reloadEntity() as this may clear all the fields.
Thanks,
Sourav Kumar Samal
Hello,
Could you please clarify how exactly the manually validation functionality has been achieved? Was it done by code?
Thank you in advance!
Best regards,
Anastasiia
Anastasiia Zhuravel,
Yes it has been achieved by using 'asyncValidate' function. The validation will only trigger when DCM status changed to "Business Owner Review".
Thanks,
Sourav
Anastasiia Zhuravel,
asyncValidate: function(callback, scope) { if (this.isEditMode()){ this.callParent([function(response) { if (!this.validateResponse(response)) { return; } Terrasoft.chain( function(next) { this.MandatoryValidation(function(response) { if (this.validateResponse(response)) { next(); } }, this); }, function(next) { callback.call(scope, response); next(); }, this); }, this]); }else { this.callParent(arguments); } }, MandatoryValidation: function(callback, scope){ var DCMstatus = this.get("MarketingPlansStatus").displayValue; if(DCMstatus === "Business Owner Review"){ // Some query callback.call(scope || this, { success: false, message: "Error message" }); }else{ callback.call(scope || this, { success: true }); } },
Anastasiia Zhuravel,
I have resolved the issue. To acheive the desired output I have added a small line after the error message as follows:
MandatoryValidation: function(callback, scope){ var DCMstatus = this.get("MarketingPlansStatus").displayValue; if(DCMstatus === "Business Owner Review"){ // Some query callback.call(scope || this, { success: false, message: "Error message" }); this.reloadEntity(); }else{ callback.call(scope || this, { success: true }); } },
Note: If the asynValidate is being used in this.NewMode(), avoid adding this.reloadEntity() as this may clear all the fields.
Thanks,
Sourav Kumar Samal