Skip to main content

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.

        sPXMergeAttributes(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.

Hi @jknauf ,

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

pPXMergeAttributes(Method = MergeMethod.Replace)]

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

 


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; }

}


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. 


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