# Accessing a SESSION **Category:** [Epicor ERP 10](https://www.epiusers.help/c/e10/5) **Created:** 2016-11-21 19:50 UTC **Views:** 9843 **Replies:** 18 **URL:** https://www.epiusers.help/t/accessing-a-session/36377 --- ## Post #1 by @Chris_Conn What is the proper way to access a SESSION object? I've read articles saying: Ice.Core.Session SOSession: The type or namespace name 'Session' does not exist in the namespace 'Ice.Core' (are you missing an assembly reference?) ((Mfg.Core.Session)oTrans.Session).UserName : Error CS0234: The type or namespace name 'Mfg' does not exist in the namespace 'Epicor' (are you missing an assembly reference?) I am starting to think I maybe be missing an assembly reference lol. The interesting thing is that I swear I've done this before with no issue in a Customization, but I am having issues within a BPM. --- ## Post #2 by @josecgomez Within a BPM you shouldn't need the session. You have the Db object context and the callContextClient. What do you need from the session on a BPM? --- ## Post #3 by @Chris_Conn Which DB I am operating in. I.E Test or Live --- ## Post #4 by @josecgomez this.Session.AppServerURL should work within a BPM --- ## Post #5 by @Chris_Conn Really?!?! this.Session with no casting.... lol, boy do I feel silly --- ## Post #6 by @Bart_Elia I can make it harder if you want but I might get lynched ;) Let me know if you have issues with it. There are a few advanced gymnastics in there possible when we will need that in the core app. Still waiting to see if people stumble into them in the wild ;) --- ## Post #7 by @Chris_Conn It seems the AppServerURL var is empty :( Really wishing my IT would get me access to remote debugging already :cry: --- ## Post #8 by @josecgomez Works for Me @Chris_Conn What Method are you running this on? Mine works fine --- ## Post #9 by @Chris_Conn Running this on a data directive for SYS_TASK table - alerts me by email when MRP starts/stops String serv = this.Session.AppServerURL ; message.Body = "

MRP started in Camden: "+serv+"


MRP Started by "+user+" on "+start+"
Please wait before using any MRP suggestions until the task has completed. You will be notified on completion."; Also, if you keep blanking out your server address how the hell am I supposed to target you for attacks? :stuck_out_tongue_winking_eye: --- ## Post #10 by @Chris_Conn [quote="Chris_Conn, post:9, topic:36377"] String serv = this.Session.AppServerURL ; message.Body = "<h1>MRP started in Camden: "+serv+"</h1><BR>MRP Started by "+user+" on "+start+ [/quote] Waiting on @Bart_Elia to save the day with some (NON-RESTFUL) secret code lol --- ## Post #11 by @Bart_Elia Sorry folks, this place is an after hours hang out in the lazy boy and I've had too many honey do's with the holidays fast approaching. I have not forgotten you. I'll see what I can determine about this URL property. It's one of the few I have not added personally. --- ## Post #12 by @Bart_Elia It looks like that session property is only set when called by a 'Rich Client' - The Shell or EWA base clients. It's actually used for BPM on the client. Can I brainstorm a work around with you? What are you trying to accomplish where you need this Url? --- ## Post #13 by @josecgomez He's trying to identify the current instance within a BPM for conditional logic Pilot, vs Prod etc I came up with a work around using DB_NAME() but that can open up a whole can of worms in the wrong hands so I won't post the example here. Don't want shoot yourself in the foot syndrome. Maybe you have a better idea --- ## Post #14 by @jgiese.wci I have that in a few of mine. I read the database connection string to determine path based on which I'm hitting. Joshua Giese CTO 920.437.6400 x342 Wisconsin Converting Inc. --- ## Post #15 by @Bart_Elia Oh! If you just need the machine name? System.Environment.MachineName or System.Net.Dns.GetHostName() --- ## Post #16 by @Chris_Conn I appreciate the offer but I got it going with a little assistance. Would the solution you suggest for DNS hostname work for DBs on the same server? I assume the DNS name would be the same. --- ## Post #17 by @darista [quote="Chris_Conn, post:9, topic:36377"] this.Session.AppServerURL [/quote] Hi @Chris_Conn were you able to fix this? I'm also using the SysTask table to send emails when a process gets an error but when using the Session.APPServerURL the emails are not sent, if I remove it the emails are received. --- ## Post #18 by @Chris_Conn Ah - I remember now, Session.AppServerURL didnt get populated in that context. I dont remember the exact solution but it involved some squirrely code. --- ## Post #19 by @darista Thank you I could resolve it, by doing some additional code. --- **Canonical:** https://www.epiusers.help/t/accessing-a-session/36377 **Original content:** https://www.epiusers.help/t/accessing-a-session/36377