Solved

Looking for a better way to load the current Organization in a graph extension

  • 7 February 2024
  • 2 replies
  • 21 views

Userlevel 3
Badge

I’ve added some custom fields to the Company editing screen inside Configuration that I need to access in a graph extension and a custom service class.  The fields were created as a DAC extension on Organization.  These fields are used to store company specific URLs to third party APIs.

The thing I’d like help with is coming up with a way to get to the current organization without hard coding the OrganizationCD into my FBQL query.  This is what is working for me currently:

 

var organization =

    SelectFrom<Organization>

        .Where<Organization.organizationCD.IsEqual<@P.AsString>>

        .View

    .Select(Base, "MY_ORGANIZATION_CD")

    .RowCast<Organization>()

    .FirstOrDefault();

 

Is there a better way to do this without using MY_ORGANIZATION_CD as a string? 

Originally, I was hoping I could use the CompanyID from PXInstanceHelper.CurrentCompany but IntelliSense suggests it isn’t possible to query for records using the CompanyID column.  Ideally, I’d like something that isn’t going to be expensive in terms of processing time.

icon

Best answer by Marco Villasenor 7 February 2024, 17:43

View original

2 replies

Userlevel 3
Badge +2

Hello @PorchlightZach , there is a way to get the org through the OrganizationMaint Graph:

 

using PX.Objects.GL.DAC;




Organization org = OrganizationMaint.FindOrganizationByID(this.Base, PXAccess.GetParentOrganizationID(PXContext.GetBranchID()));

 

Userlevel 3
Badge

Marco, that worked perfectly!  Thank you for sharing the information.

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