Skip to main content
Answer

CacheAttached - override the override

  • December 6, 2022
  • 4 replies
  • 1011 views

Forum|alt.badge.img+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.

Best answer by rjean09

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:

 

4 replies

Leonardo Justiniano
Jr Varsity II
Forum|alt.badge.img+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


Forum|alt.badge.img+1
  • Author
  • Semi-Pro III
  • Answer
  • December 9, 2022

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:

 


Forum|alt.badge.img+1
  • Author
  • Semi-Pro III
  • December 9, 2022

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.


darylbowman
Captain II
Forum|alt.badge.img+15

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

Thank you!