Get Current Company Name

Hi All,

Want to give you a short trick – how to extract company name from the currently logged in user:

Company Name

PX.Data.PXLogin.ExtractCompany(PX.Common.PXContext.PXIdentity.IdentityName)

Here we have 2 things:

  • PXSessionContext (PXContext.PXIdentity) – System class that stores environment variables in session like User, TimeZone, Branch, Locale. Actually this is used for user authentication authorization. However user here is stored with a full notation – like “user@company:branch”. But we can cut a part of it using special rules.
  • PXLogin – set of tools that can help to login user and use username. In our case it can extract company name right from full identity name.

Company ID

PX.Data.Update.PXInstanceHelper.CurrentCompany

Here we have an PXInstanceHelper class that helps to get some environment variables, like currently logged in company, site folder, IIS version, Database Name, IP Address.

Hope it helps!

Leave a Reply

Please rate*

Your email address will not be published. Required fields are marked *