Use oTrans.Session To Determine Epicor Session Variables
During the process of developing customizations, you may find yourself needing to know various things in order for your code to work. Examples might be:
What is the user ID/email address/name of the user that is logged into Epicor?
What AppServer are they logged into?
What is the name and ID of the company they are currently in?
What plant are they in?
Fortunately, Epicor gives us access to a ton of these details via oTrans.Session. In order to access these Epicor session variables, you must cast oTrans.Session as Ice.Core.Session and from there any property can follow. For example, for the property UserName:
string name = ((Ice.Core.Session)oTrans.Session).UserName; MessageBox.Show("Hi " + name + ", it is nice to meet you.");
There are a bunch of properties available - here is a listing of the ones I have found most useful:
Property | Description | Example |
---|---|---|
AppServer | The AppServer URL for the database you are currently logged into. | net.tcp://MY-SERVER/EpicorERP |
CompanyID | The company ID you are currently logged into. | ACME |
CompanyName | The company name you are currently logged into. | ACME Corp. |
EmployeeID | The employee ID associated with the user logged in. | aellis |
PlantID | The plant ID you are currently logged into. | MfgSys |
PlantName | The plant name you are currently logged into. | Minneapolis Plant |
TaskClientID | The ID associated to your current client. This is important if you want to submit a report to the system monitor so that it correctly pops up on your screen. | ADAMELLISDDE7 adamellis |
UserEmail | The email address associated with the logged in user. | aellis@gingerhelp.com |
UserName | The name associated with the logged in user. | Adam Ellis |
WorkstationDescription | If there is a workstation associated with this session, the description as defined. This is mainly used for shipping workstations. | Shipping Terminal 001 |
WorkstationID | If there is a workstation associated with this session, the ID as defined. This is mainly used for shipping workstations. | Shipping001 |