79379589

Date: 2025-01-23 01:27:55
Score: 0.5
Natty:
Report link

You need to extend PrimartContactGraphExt, and implement your check there.

using PX.Data;
using PX.Objects.CR;

namespace StackOverFlowDemo
{
    // Acuminator disable once PX1016 ExtensionDoesNotDeclareIsActiveMethod extension should be constantly active
    public class PrimaryContactGraphExtExt : PXGraphExtension<BusinessAccountMaint.PrimaryContactGraphExt, BusinessAccountMaint>
    {
        protected virtual void _(Events.RowPersisting<Contact> e)
        {
            if (e.Row?.IsPrimary != true) return;

            if (e.Row.EMail == null)
            {
                // Acuminator disable once PX1050 HardcodedStringInLocalizationMethod [Justification]
                e.Cache.RaiseExceptionHandling<Contact.eMail>(e.Row, e.Row.EMail,
                    new PXSetPropertyException<Contact.eMail>("Email address must not be empty for primary contacts.", PXErrorLevel.RowError));
            }
        }  
    }
}
Reasons:
  • Blacklisted phrase (1): StackOverFlow
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: Zoltan Febert