Want to give you a short trick – how to extract company name from the currently logged in user:
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.
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!