Skip to main content
Answer

Overriding Inventory data views which use FbqlSelect and SelectFromBase

  • December 16, 2022
  • 9 replies
  • 553 views

Tony Lanzer
Pro III
Forum|alt.badge.img+2

I’m trying to override a data view used in Stock Items and Non-Stock Items screens, and in the abstract InventoryItemMaintBase graph class -- the view named itemxrefrecord that is used in the Cross-Reference tab grid.  The view, like most in this base class, uses FbqlSelect and SelectFromBase instead of just SelectFrom (see definition below).  This graph class seems to be the only one in the framework that uses this syntax for some reason (at least that’s what I’ve seen from a quick code search).

public FbqlSelect<SelectFromBase<INItemXRef, TypeArrayOf<IFbqlJoin>.Empty>.Where<PX.Data.ReferentialIntegrity.Attributes.KeysRelation<PX.Data.ReferentialIntegrity.Attributes.Field<INItemXRef.inventoryID>.IsRelatedTo<InventoryItem.inventoryID>.AsSimpleKey.WithTablesOf<InventoryItem, INItemXRef>, InventoryItem, INItemXRef>.SameAsCurrent>, INItemXRef>.View itemxrefrecords;

This syntax uses a lot of keywords that would take a long time to decipher enough to add a second join condition, so I tried to override it with typical SelectFrom syntax instead (see below).  I just want to add a join to BAccount to grab the Vendor name.

public SelectFrom<INItemXRef>
.InnerJoin<InventoryItem>.On<INItemXRef.inventoryID.IsEqual<InventoryItem.inventoryID>>
.InnerJoin<BAccount>.On<INItemXRef.bAccountID.IsEqual<BAccount.bAccountID>>
.Where<INItemXRef.inventoryID.IsEqual<InventoryItem.inventoryID.FromCurrent>>.View itemxrefrecords;

It worked to get the Vendor name showing in the grid, but when testing it and attempting to add a row in the grid and save, it fails with the “Another process has added the INItemXRef record”.  Any guidance on how to override the original existing FbqlSelect data view to add a join, or how to resolve the error in my SelectFrom version?  I can probably extend the DAC and add a calculated field to resolve it so that I don’t need a join, but it seemed like the join was a simpler solution -- if it would work.

Best answer by Tony Lanzer

@aaghaei Interesting.  Thanks for trying this, but it wouldn’t work for me -- hence my post.  Maybe it’s an issue with the version -- 22.107.  What version are you working with in which it works?  To get it to work without error, I ended up adding a calculated field populated in an event.

9 replies

aaghaei
Captain II
Forum|alt.badge.img+10
  • Captain II
  • December 16, 2022

@tlanzer25 

The below link will help you to override your view using a view delegate:

https://asiablog.acumatica.com/2016/06/using-pxview-in-dataview-delegate.html

 

 


Tony Lanzer
Pro III
Forum|alt.badge.img+2
  • Author
  • Pro III
  • December 16, 2022

Thanks @aaghaei, but I don’t want to use a view delegate just to pull in an extra column value.


aaghaei
Captain II
Forum|alt.badge.img+10
  • Captain II
  • December 17, 2022

@tlanzer25 

I understand we all want to keep the coding and changes to a minimum but If you want to override a built-in public standard view, you will need to either develop a view delegate or overrode your graph Initialize() to properly work as far as I know. 


Tony Lanzer
Pro III
Forum|alt.badge.img+2
  • Author
  • Pro III
  • December 17, 2022

@aaghaei Actually, you only need to create a view with the same name in a graph extension to override a graph view -- that’s what I’m doing now.


aaghaei
Captain II
Forum|alt.badge.img+10
  • Captain II
  • December 17, 2022

@tlanzer25  The problem with what are you doing is if Acumatica in future releases changes the view structure, users won't be able to open the screen at all. You can proceed as you wish and think best works for you though.


Tony Lanzer
Pro III
Forum|alt.badge.img+2
  • Author
  • Pro III
  • December 17, 2022

@aaghaei The same could be said for a delegate that is no longer compatible. I disagree.


aaghaei
Captain II
Forum|alt.badge.img+10
  • Captain II
  • December 17, 2022

@tlanzer25 

 

I tested the below Code (It is actually yours but I am not sure about the Graph Ext and the rest of your code) and works just fine the way you wanted to develop it.

Here I am copying the full code in case yours is slightly different:

using PX.Data;
using PX.Data.BQL.Fluent;
using PX.Objects.CR;


namespace PX.Objects.IN
{
public class InventoryItemMaintExt : PXGraphExtension<PX.Objects.IN.InventoryItemMaint>
{
public static bool IsActive() => true;

public SelectFrom<INItemXRef>
.InnerJoin<InventoryItem>.On<INItemXRef.inventoryID.IsEqual<InventoryItem.inventoryID>>
.InnerJoin<BAccount>.On<INItemXRef.bAccountID.IsEqual<BAccount.bAccountID>>
.Where<INItemXRef.inventoryID.IsEqual<InventoryItem.inventoryID.FromCurrent>>
.View itemxrefrecords;
}
}

 

And here is a snip from the data I entered as you see it is saved and the save button is disabled now.

 

 


Tony Lanzer
Pro III
Forum|alt.badge.img+2
  • Author
  • Pro III
  • Answer
  • December 17, 2022

@aaghaei Interesting.  Thanks for trying this, but it wouldn’t work for me -- hence my post.  Maybe it’s an issue with the version -- 22.107.  What version are you working with in which it works?  To get it to work without error, I ended up adding a calculated field populated in an event.


aaghaei
Captain II
Forum|alt.badge.img+10
  • Captain II
  • December 17, 2022

@tlanzer25 i tested on 21.205