Skip to main content
Solved

Extend a Nonexistent table/DAC

  • 18 July 2024
  • 3 replies
  • 59 views

Hi, I’d like to extend the InventoryAllocDetEnqResult DAC which provides data to the grid on the ‘Inventory Allocation Details’ screen.

I’ve used the following code to extend the DAC and extend a method on the graph.

public class InventoryAllocDetEnqResultExt : PXCacheExtension<PX.Objects.IN.InventoryAllocDetEnqResult>
{
public static bool IsActive() => true;
#region UsrUOM
OPXString(10)]
)PXUIField(DisplayName = "UOM")]

public virtual string UsrUOM { get; set; }
public abstract class usrUOM : PX.Data.BQL.BqlString.Field<usrUOM> { }
#endregion
}
public class InventoryAllocDetEnq_Extension : PXGraphExtension<PX.Objects.IN.InventoryAllocDetEnq>
{
public delegate IEnumerable<InventoryAllocDetEnqResult> CalculateResultRecordsDelegate();
)PXOverride]
public IEnumerable<InventoryAllocDetEnqResult> CalculateResultRecords(CalculateResultRecordsDelegate baseMethod)
{
IEnumerable<InventoryAllocDetEnqResult> p = baseMethod();
foreach (InventoryAllocDetEnqResult record in p)
{
record.GetExtension<InventoryAllocDetEnqResultExt>().UsrUOM = "EACH";
}
return p;
}
}

Everything compiles, but when I attempt to access the extension I get the error - ‘GetItemExtension failed’.

One thing to point out is that the view which uses the DAC is a non-existent table, the data in the table is added when required and not extracted directly from a SQL table.

I cannot understand why this is happening? As anyone seen this before?

3 replies

Badge +12

I can’t really see any issues with your code. The only somewhat odd thing I’m noticing is the way they handle the data view. The method that you’re overriding is used BY the data view delegate, but is not the actual data view delegate. Interesting design.

I’m curious if your goal is simply to assign ‘EACH’ to each field? If so, you could try [PXUnboundDefault("EACH")] or something like that to set the value in a different way. Not sure if this would get around needing to use GetExtension() or not.

Userlevel 4
Badge +1

The goal is to be able to set the value, rather than default it. So I think I will need to use GetExtension(). 

Badge +12

It seems like it may have something to do with how the faux data view is initialized:

protected Lazy<IEnumerable<InventoryAllocDetEnqResult>> cachedResultRecords;

 

Reply