Search code examples
acumatica

Changing visibility of shared Contact field on Customers screen in 2020R2?


I need to set Visible state of the Primary Contact->Email field on the Customers screen (General tab) to hidden.

In 2020R2 it's not clear to me how these Views are implemented. They have the same names, but seem to work differently than previous versions of Acumatica. In the version I'm upgrading from, 2019R1, the Primary Contact section doesn't exist.

I've created this event handler to hide the email field. But, it hides ALL the email fields: Both instances on the General tab, and also on the Billing and Shipping tabs. I only want to hide the field in the Primary Contact grouping.

protected virtual void _(Events.RowSelected<Contact> e)
{
    PXUIFieldAttribute.SetVisible<Contact.eMail>(e.Cache, e.Row, false);
}

Is there a way to target just the Primary Contact email field with an event handler? When that field is inspected, the view name is: PrimaryContactCurrent. This view doesn't seem to exist in CodeRepository\CustomerMaint.cs, so I'm not sure how to target it with an event handler.

enter image description here


Solution

  • In 20R2 the logic for Contacts managements is located in separate graph extension CRPrimaryContactGraphExt and the PrimaryContactCurrent is defined there.

    However, I don't think that's what you need. You are on the right track with the RowSelected event. You just need to add a condition to hide only needed field.

    protected virtual void _(Events.RowSelected<Contact> e)
    {
      if(e.Row?.ContactID==Base.BAccount.Current?.PrimaryContactID)
        PXUIFieldAttribute.SetVisible<Contact.eMail>(e.Cache, e.Row, false);
    }