Accessing a SESSION

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.

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?

Which DB I am operating in. I.E Test or Live

this.Session.AppServerURL should work within a BPM

2 Likes

Really!!! this.Session with no casting… lol, boy do I feel silly

1 Like

I can make it harder if you want but I might get lynched :wink:

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 :wink:

1 Like

It seems the AppServerURL var is empty :frowning:

Really wishing my IT would get me access to remote debugging already :cry:

Works for Me @Chris_Conn
What Method are you running this on? Mine works fine

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 = "<h1>MRP started in Camden: "+serv+"</h1><BR>MRP Started by "+user+" on "+start+"<BR>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:

Waiting on @Bart_Elia to save the day with some (NON-RESTFUL) secret code lol

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.

1 Like

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?

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

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.

Oh! If you just need the machine name?

System.Environment.MachineName
or
System.Net.Dns.GetHostName()

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.

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.

Ah - I remember now, Session.AppServerURL didnt get populated in that context. I dont remember the exact solution but it involved some squirrely code.

1 Like

Thank you I could resolve it, by doing some additional code.