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


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


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!

2 Replies to “Get Current Company Name”

  1. Hi Sergey,

    I’m trying to add custom field which will be defaulted to the current CompanyKey value
    I can get company name using [PXDefault(typeof(AccessInfo.companyName))] but I need company key

    Can you advise on this?

Leave a Reply

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