Solved

What is the purpose of the first parameter of PXGraph when making PXSelect calls?

  • 21 September 2022
  • 3 replies
  • 194 views

Userlevel 7
Badge +5

As I wrap my brain further around the framework I’m starting to ask myself questions on the ‘why’ I am coding things the way that I’ve coding so I get better at all of this.

I’m not entirely certain what the first graph parameter of a PXSelect is being used for. I think I’ve read somewhere that I shouldn’t generate a generic PXGraph for the first parameter.

So, in this example, I can see how my soOrderEntry graph becomes the source of the query so that it will return the lines from the soOrderEntry record that it currently holds.

var lines = SelectFrom<SOLine>.
Where<SOLine.orderType.IsEqual<SOOrder.orderType.FromCurrent>
.And<SOLine.orderNbr.IsEqual<SOOrder.orderNbr.FromCurrent>>>
.OrderBy<Desc<SOLine.lineNbr>>
.View.Select(soOrderEntry);

But, in the case where I need to find, say, a warehouse code and I use:

INSite iNSite = INSite.PK.Find(this, siteID);

I’ve used ‘this’ because this code resides within a Graph Extension. This is a stand alone query so my question is, what is the purpose/relevance to what graph that I use for the INSite lookup?

Is it in relation to the cache of ‘this’ so that a subsequent call would potentially be more efficient?

Is there a disadvantage or an unintended consequence to calling:

INSite iNSite = INSite.PK.Find(soOrderEntry, siteID);

 

icon

Best answer by Leonardo Justiniano 21 September 2022, 19:55

View original

3 replies

Userlevel 6
Badge +4

Hi @ddunn 

Any BQL query run in the context of a Graph. When you create a graph for a screen you usually pass the current graph context (this). If You are extending an existing graph you have to pass the original graph (Base, Base1,...) 

 

Userlevel 7
Badge +5

Thank you!

Userlevel 2
Badge +1

You will notice that sometimes you will use static methods (for which you need to pass the PXGraph instance).  Other time, you will use instance values (such as your PXSelect queries), then you won’t need to pass it since it is already connected with the Graph.  Anyhow, like Leonardo said, all queries run in conjonction with the PXGraph instance since the data is stored in PXCache instances inside of the PXGraph.

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