Hi Community,
I am trying to add a field validation via javascript code using the below article.
https://academy.creatio.com/docs/developer/getting_started/develop_appl…
While I am trying the validation, I am getting an error in the console as in the screenshot below. It says "Cannot read properties of undefined (reading 'invalidMessage')." I am initiating a null value in the method as described in the above article. What am I missing here? I cannot add validation to any fields because of this error. I have also added my code snippet below.
onEntityInitialized: function() {
this.callParent(arguments);
this.onBooleanChange();
this.changeColor();
this.setYearEnd();
this.setNumberOfDaysInApplicationCreationStage();
this.accountHolderValidator();
},
setValidationConfig: function() {
this.callParent(arguments);
//this.addColumnValidator("BEALMDateofBirth", this.dateOfBirthValidator);
this.addColumnValidator("BEALMAccountHolderType", this.accountHolderValidator);
},
accountHolderValidator: function() {
var invalidMessage = "";
var lead = this.get("BEALMLead").value;
var scope = this;
var esq = Ext.create("Terrasoft.EntitySchemaQuery", {
rootSchemaName: "Lead"
});
esq.addColumn("Id");
esq.addColumn("BEALMIsPAHExist");
var esqFilter = esq.createColumnFilterWithParameter(Terrasoft.ComparisonType.EQUAL, "Id", lead);
esq.filters.add("esqFilter", esqFilter);
esq.getEntityCollection(function (result) {
if (result.success) {
var isPAHExist = result.collection.collection.items[0].values.BEALMIsPAHExist;
if (isPAHExist == true) {
invalidMessage = this.get("Resources.Strings.BEALMInvalidAccountHolderMessage");
}
else {
invalidMessage = "";
}
return {
invalidMessage: invalidMessage
};
}
});
},
Please help to resolve this issue.
Thank you
Cheers!