What's wrong with this code?

Hey, I need some sharper eyes than mine.

In the ABC Code customization I have this:

	public void InitializeCustomCode()
	{
		// ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Variable Initialization' lines **
		// Begin Wizard Added Variable Initialization
		EpiDataView edvCallContextClient = (EpiDataView)(oTrans.EpiDataViews["CallContextClient"]);
		string user = edvCallContextClient.CurrentDataRow["CurrentUserId"].ToString();

The first statement runs okay. The second gives me:

Message: Exception has been thrown by the target of an invocation.
Inner Exception Message: Object reference not set to an instance of an object.
Program: CommonLanguageRuntimeLibrary
Method: InvokeMethod

I know I can get the current user ID another way but I need to have the dataview to pass the current ID to a BAQ.

Thanks,

Joe

Doh. CallContextClientData

2 Likes

I prefer:

oTrans.CoreSession.UserID;

It requires only one line of code.

Thanks, Jason.

using Ice.Core; //add ref dll: Ice.Core.Session.dll

string UserID = ((Ice.Core.Session)this.oTrans.Session).UserID;

As you can see from the above code, this is a lot more work than simply:

string UserID = oTrans.CoreSession.UserID; //no dll needed