0
votes

Using [VendorActive] attribute in ExpenseClaim displays only employee, I read an article about DAC Inheritances, I need to use BAccount2, I tried that option but it seems my field doesn't read my Selector, my question is how will I use VendorActive as if it is in AP Module?

2

2 Answers

1
votes

This happens because of cache inheritance. Employee is inherited from Vendor. If the first cache that was initialized is Employee, Vendor record will not initialize its own cache. It will instead use Employee one, that leads to the described behavior. Try adding following code to the graph Extension Initialize method:

    public override void Initialize()
    {
        var cache = Base.Caches[typeof(Vendor)];
        PXTrace.WriteWarning(cache.GetType().ToString());
    }

This will allow you to observe cache type in Trace window and it should also initialize Vendor cache before Employee cache.

0
votes

I have run into that too but couldn't find a proper fix because I have failed to reproduce the problem consistently. It's either a bug in the vendor attribute or the ORM.

I think the bug occurs in conjunction with other operation that modifies the BAccount cache. When I did IISReset/Restart Application to clear all caches, the selector behavior changed. Behavior was also affected when I opened an employee selector before the vendor selector.

Since I can't reproduce issue easily I can't provide a reliable fix but you could try setting CacheGlobal = false and DirtyRead = false. If the bug is related to cache ORM this would help by ensuring data is taken more directly from database:

public abstract class vendorID : IBqlField { }

[PXUIField(DisplayName = "Vendor", Enabled = true)]
[VendorActive(Visibility = PXUIVisibility.SelectorVisible,
                DescriptionField = typeof(Vendor.acctName),
                Filterable = true, 
                CacheGlobal = false,
                DirtyRead = false)]
public virtual int? VendorID { get; set; }