Hi Team,
I'm currently working on implementing validation for fields like MobilePhone, Email, and HomePhone under the Communication Options section on the Contact_FormPage
.
However, I couldn’t find any relevant component or configuration in the Contact_FormPage
source code that would allow me to add validation using handler or validator methods directly.
I considered using an Entity Event Listener to handle the validation logic, but I noticed that an event handler file already exists in the CrtBase
package. Since this file is part of a system package, I’m unable to modify it.

(source-code)
namespace Terrasoft.Configuration
{
using System;
using Terrasoft.Common;
using Terrasoft.Core;
using Terrasoft.Core.DB;
using Terrasoft.Core.Entities;
using Terrasoft.Core.Entities.Events;
using Terrasoft.Core.ExternalUsers;
using Terrasoft.Core.Factories;
#region Class: ContactCommunicationEventListener
[EntityEventListener(SchemaName = "ContactCommunication")]
public class ContactCommunicationEventListener: BaseEntityEventListener
{
#region Methods: Private
private bool GetIsExternalUserCommunication(Guid contactId, UserConnection userConnection) {
var select = new Select(userConnection)
.Count("Id")
.From("SysAdminUnit")
.Where("ContactId").IsEqual(Column.Parameter(contactId))
.And("ConnectionType").IsEqual(Column.Parameter(UserType.SSP)) as Select;
var externalUsersCount = select.ExecuteScalar();
return externalUsersCount != 0;
}
#endregion
#region Methods: Public
public override void OnSaving(object sender, EntityBeforeEventArgs e) {
base.OnSaving(sender, e);
var entity = (Entity)sender;
var communicationTypeId = entity.GetTypedColumnValue("CommunicationTypeId");
if (communicationTypeId != Guid.Parse(CommunicationTypeConsts.EmailId)) {
return;
}
var contactId = entity.GetTypedColumnValue("ContactId");
var userConnection = entity.UserConnection;
if (!GetIsExternalUserCommunication(contactId, userConnection)) {
return;
}
var email = entity.GetTypedColumnValue("Number");
var emailValidator = ClassFactory.Get();
var isEmailValid = emailValidator.IsValidEmailDomainForExternalUser(email);
if (!isEmailValid) {
string message = new LocalizableString(userConnection.ResourceStorage,
"ContactCommunicationEventListener", "LocalizableStrings.ErrorMessage.Value");
throw new SSPRestrictedEmailDomainException(message);
}
}
#endregion
}
#endregion
}
Could you please advise on:
- The recommended approach to implement validation for these communication fields?
- Whether there’s a supported way to override or extend existing entity event logic from a system package?