Solved

Override DAC Attributes

  • 13 April 2021
  • 4 replies
  • 761 views

Userlevel 3
Badge

I am attempting to override Acumatica’s default Primary Item Validation logic. The base logic is done through an attribute, specifically the PrimaryItemRestrictorAttribute, which is subscribed to by the LocationAvailAttribute. So to override this, I made my own UsrPrimaryItemRestrictorAttribute and UsrLocationAvailAttributes, and figured I’d use the standard PXMergeAttributes attribute in the cache attached event in the graphs I would like to manipulate, effectively replacing the original attribute with my new ones on these screens. Below is an example of this in the INAdjustmentEntry graph. Remember the UsrLocationAvailAttributes subscribes to UsrPrimaryItemRestrictorAttribute.

        [PXMergeAttributes(Method = MergeMethod.Append)]
[PXRemoveBaseAttribute(typeof(LocationAvailAttribute))]
[UsrLocationAvail(typeof(INTran.inventoryID), typeof(INTran.subItemID), typeof(INTran.siteID), typeof(INTran.tranType), typeof(INTran.invtMult))]
protected void INTran_LocationID_CacheAttached(PXCache sender) { }


Now when I test the logic it’s clearly running my code, ​​​​but it seems to also run the code for the original attributes, which should be removed at this point. I can see this from the stack trace, which I’ll include below. As you can see it’s throwing the standard error that should appear with Acumatica’s default Item Validation logic, and is even referencing the original attribute in the stack trace, even though I can see it’s running my code from the screen and can step through it in the debugger.

 



Am I missing something? Maybe is there another reference to the LocationAvail attribute I’m missing? Any suggestions would be great, or if you have an alternate approach to adjusting attribute logic, I’m all ears. Thanks.

icon

Best answer by Hughes Beausejour 14 April 2021, 16:56

View original

4 replies

Userlevel 7
Badge +17

Hi @jknauf ,

Did you try with below MergeMethod as “Replace”, like below?

[PXMergeAttributes(Method = MergeMethod.Replace)]

If this is still NOT working, can you please share the customized attribute code?

 

Userlevel 5
Badge +2

The stack trace points to LSINTran which is also declared in INRegisterEntryBase. This might explain why CacheOverride doesn’t apply.


public class INAdjustmentEntry : INRegisterEntryBase, IGraphWithInitialization

{

         public override LSINTran LSSelectDataMember => lsselect;

}

public abstract class INRegisterEntryBase : PXGraph<PXGraph, INRegister>, IGraphWithInitialization
{
        public abstract LSINTran LSSelectDataMember { get; }

}

Userlevel 3
Badge

I did try it with replace, as well as not including the Merge Attribute at all but neither works. And at this point I’m really just trying to successfully remove the PrimaryItemRestrictorAttribute. I’ve removed my customized attribute entirely to focus on removing the base attribute, but it still seems to run even when I use cache attached and PXRemoveBaseAttribute. 

Userlevel 3
Badge

The stack trace points to LSINTran which is also declared in INRegisterEntryBase. This might explain why CacheOverride doesn’t apply.


public class INAdjustmentEntry : INRegisterEntryBase, IGraphWithInitialization

{

         public override LSINTran LSSelectDataMember => lsselect;

}

public abstract class INRegisterEntryBase : PXGraph<PXGraph, INRegister>, IGraphWithInitialization
{
        public abstract LSINTran LSSelectDataMember { get; }

}



This is interesting, I’ll look into this. Thanks for the lead!

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