Solved

Overriding Inventory data views which use FbqlSelect and SelectFromBase

  • 16 December 2022
  • 9 replies
  • 268 views

Userlevel 4
Badge +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.

icon

Best answer by Tony Lanzer 17 December 2022, 05:17

View original

9 replies

Userlevel 7
Badge +8

@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

 

 

Userlevel 4
Badge +2

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

Userlevel 7
Badge +8

@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. 

Userlevel 4
Badge +2

@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.

Userlevel 7
Badge +8

@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.

Userlevel 4
Badge +2

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

Userlevel 7
Badge +8

@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.

 

 

Userlevel 4
Badge +2

@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.

Userlevel 7
Badge +8

@tlanzer25 i tested on 21.205

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