Solved

CacheAttached - override the override

  • 6 December 2022
  • 4 replies
  • 503 views

Userlevel 3
Badge +1

I am attempting to override the DAC attribute of TXAvalaraCustomerUsageType with a custom derivative. It is working on DAC extensions, however, there are some existing graphs that are already overriding with CacheAttached and if I try to do my own graph extension, it is not applying my change.  For example:

CustomerMaint has this:

[PXDBString(1, IsFixed = true, BqlField = typeof(PX.Objects.CR.Standalone.Location.cAvalaraCustomerUsageType))]
[PXUIField(DisplayName = "Entity Usage Type", Required = true)]
[TXAvalaraCustomerUsageType.List]
[PXDefault("0", typeof(Search<CustomerClass.avalaraCustomerUsageType, Where<CustomerClass.customerClassID, Equal<Current<Customer.customerClassID>>>>))]
protected virtual void _(Events.CacheAttached<PX.Objects.CR.Standalone.Location.cAvalaraCustomerUsageType> e)
{
}

And I am trying to change the TXAvalaraCustomerUsageType.List (note: this is what’s in the code but the class is actually TXAvalaraCustomerUsageType.ListAttribute)

[PXRemoveBaseAttribute(typeof(TX.TXAvalaraCustomerUsageType.ListAttribute))]
[PXMergeAttributes(Method = MergeMethod.Append)]
[AvalaraCustomerUsageTypeAttribute1]
protected virtual void _(Events.CacheAttached<PX.Objects.CR.Standalone.Location.cAvalaraCustomerUsageType> e)
{
}

This is not working, but my attribute is good and it works in DAC extensions using 

[PXRemoveBaseAttribute(typeof(TX.TXAvalaraCustomerUsageType.ListAttribute))]
[PXMergeAttributes(Method = MergeMethod.Append)]
[AvalaraCustomerUsageTypeAttribute1]
public string AvalaraCustomerUsageType { get; set; }

But not working in cacheattached to override CustomerMaint.

Notice I have to use TXAvalaraCustomerUsageType.ListAttribute because TXAvalaraCustomerUsageType.List does not resolve to anything in the codebase, and yet, CustomerMaint class shows it as thus.

icon

Best answer by rjean09 9 December 2022, 15:45

View original

4 replies

Userlevel 6
Badge +4

Hi @rjean09 

Did you try replacing the whole set of attributes?

[PXMergeAttributes(Method = MergeMethod.Replace)]
[PXDBString(1, IsFixed = true, BqlField = typeof(CR.Standalone.Location.cAvalaraCustomerUsageType))]
[PXUIField(DisplayName = "Entity Usage Type", Required = true)]
[AvalaraCustomerUsageTypeAttribute1]
[PXDefault(TXAvalaraCustomerUsageType.Default,
typeof(Search<AR.CustomerClass.avalaraCustomerUsageType,
Where<AR.CustomerClass.customerClassID,
Equal<Current<AR.Customer.customerClassID>>>>))]
protected virtual void _(Events.CacheAttached<CRLocation.cAvalaraCustomerUsageType> e) { }

Also I noticed that your extension is named attribute1 with a “ 1 “ at the end. You should avoid that and have it renamed to, for example, AvalaraCustomerUsageTypeExtAttribute. Then you can use it as 

[AvalaraCustomerUsageTypeExt]

 

Hope this helps

Userlevel 3
Badge +1

Got the solution from dev support.  I didn’t notice that although the cache attached is in the CustomerMaint.cs file, it is actually a different class (DefLocationExt)

 

So the solution is just to create a graph extension on the correct graph:

 

Userlevel 3
Badge +1

Update: the above code works, but was getting an error publishing.

See this stackoverflow: https://stackoverflow.com/questions/71531520/graph-extension-is-marked-as-pxoverride-but-the-original-method-with-such-nam

Was able to correct by just adding DefContactAddressExt to the graph extension declaration.

Badge +11

Was able to correct by just adding DefContactAddressExt to the graph extension declaration.

Thank you!

Reply


About Acumatica ERP system
Acumatica Cloud ERP provides the best business management solution for transforming your company to thrive in the new digital economy. Built on a future-proof platform with open architecture for rapid integrations, scalability, and ease of use, Acumatica delivers unparalleled value to small and midmarket organizations. Connected Business. Delivered.
© 2008 — 2024  Acumatica, Inc. All rights reserved