Skip to main content
Solved

Syntax for Getting Reference to Customer Extension in Event Handler

  • January 19, 2025
  • 1 reply
  • 21 views

Forum|alt.badge.img
  • Jr Varsity III
  • 20 replies

I’ve read through a bunch of posts here and on Stack Overflow but haven’t found an answer that works.  I want to extend Customer with a form on a custom tab using a set of fields from a custom table, rather than the user field approach which will add fields to the BAccount table and thus the other entities that share that definition.  I created a custom table then a customization project with the DAC schema definition, extended screen AR.30.30.00 with a new tab, added a form to the tab, and then bound my view for the custom DAC to the form.  Now for starters, I want to make the tab conditionally visible on customer class ID using the RowSelected event.  Based on the T210 training, I assume I need to get a reference to the extension then set the tab to visible if it’s set to not visible generally.  I can’t seem to get the syntax correct for the extension variable.  I either get the CS0120 (Object reference required...) error or the CS0311 (Type...can’t be used as type ‘TNode’...) error no matter how I adjust the syntax.  Can you tell me what the correct syntax would be to get the instance of the extension in the event handler and then how to reference the name of the custom tab?  Thanks.

Table: ZZCustomerDealerExt

DAC: ZZCustomerDealerExt

View: CustomerDealerExt

using PX.Objects.AR;
using ARCustomerDealerExt;
using static PX.Objects.TX.CSTaxCalcType;

namespace PX.Objects.AR
{
    // Acuminator disable once PX1016 ExtensionDoesNotDeclareIsActiveMethod extension should be constantly active
    public class CustomerMaintExt : PXGraphExtension<PX.Objects.AR.CustomerMaint>
  {
    #region Event Handlers

    protected void _(Events.RowSelected<Customer> e)
    {
      var customer = e.Row;

      if (customer == null)
        return;

//    var customerExt = customer.GetExtension<CustomerMaintExt>();

      CustomerMaintExt customerExt = PXCache<CustomerMaint>.GetExtension<CustomerMaintExt>(customer);

      bool enableFields = customerExt != null && customer.CustomerClassID == "DEALER";

//      PXUIFieldAttribute.SetEnabled<CustomerMaintExt.tabname?>(e.Cache, e.Row, enableFields);

    }

    #endregion

    public PXSelect<ZZCustomerDealerExt,Where<ZZCustomerDealerExt.bAccountID,Equal<Current<Customer.bAccountID>>>>
      CustomerDealerExt;

  }
}

 

Best answer by bbohn

To answer my own question, after watching T210 back again and reviewing the Visual Studio error descriptions more closely, I realized that “GetExtension” is for getting a reference to a DAC extension, which I don’t have with a custom table, not a reference to the elements of the entire extension.  Acumatica rookie mistake.  I found the following blog about hiding tabs which indicates that if you hide all of the form elements, the tab is automatically hidden:

https://asiablog.acumatica.com/?p=5167

 

So the code simply is

    protected void _(Events.RowSelected<Customer> e)
    {
      var customer = e.Row;

      if (customer == null)
        return;

      CustomerDealerExt.Cache.AllowSelect = customer.CustomerClassID == "MYCUSTCLASS";

    }

 

View original
Did this topic help you find an answer to your question?

1 reply

Forum|alt.badge.img
  • Author
  • Jr Varsity III
  • 20 replies
  • Answer
  • January 19, 2025

To answer my own question, after watching T210 back again and reviewing the Visual Studio error descriptions more closely, I realized that “GetExtension” is for getting a reference to a DAC extension, which I don’t have with a custom table, not a reference to the elements of the entire extension.  Acumatica rookie mistake.  I found the following blog about hiding tabs which indicates that if you hide all of the form elements, the tab is automatically hidden:

https://asiablog.acumatica.com/?p=5167

 

So the code simply is

    protected void _(Events.RowSelected<Customer> e)
    {
      var customer = e.Row;

      if (customer == null)
        return;

      CustomerDealerExt.Cache.AllowSelect = customer.CustomerClassID == "MYCUSTCLASS";

    }

 


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings