I want to confirm the difference of 2 local variables Session.CompanyID and callContextClient.CurrentCompany
Session.CompanyID: assigned only at login and stored for the duration of a session
callContextClient.CurrentCompany: get the correct information of the company you are standing for in case you use it for many companies when you log in at company A and you switch to company B
In bpm and customization, you should use the CurrentCompany variable instead of the CompanyID variable, also depending on the case you want to determine which company you used to initially login at, then use CompanyID
in customization:
string companyCurrent = string.Empty;
EpiDataView edvClientData = (EpiDataView)(oTrans.EpiDataViews["CallContextClientData"]);
companyCurrent = edvClientData.dataView[edvClientData.Row]["CurrentCompany"].ToString();
string companyCurrent = string.Empty;
EpiDataView edvClientData = (EpiDataView)(oTrans.EpiDataViews["CallContextClientData"]);
companyCurrent = edvClientData.dataView[edvClientData.Row]["CurrentCompany"].ToString();
session = (Session)this.oTrans.Session;
MessageBox.Show("callContextClient.CurrentCompany :" + companyCurrent +"\n Session.CompanyID: " + session.CompanyID.ToString());
I checked again, maybe when the change company system doesn’t recognize the change, there will be a difference between the two variables
depending on where you initiate the session in the desktop
in BPM:
//kiểm tra dữ liệu trước khi lưu để có thể làm được báo cáo dự toán Forecast của khách hàng cho sale
foreach(var i in ttForecast.Where(w=>w.Company==callContextClient.CurrentCompany && (w.RowMod=="A" || w.RowMod=="U")).ToList())
{
if (String.IsNullOrEmpty(i.ShortChar01))
{
throw new Ice.BLException("DMS-DataForecast-DMS_CheckForecastPeriod: This Forecast does not have PeriodType!\nPlease select PeriodType!");
}
if (String.IsNullOrEmpty(i.ShortChar06))//Year Issue
{
throw new Ice.BLException("DMS-DataForecast-DMS_CheckForecastPeriod: This Forecast does not have Year Issue!\nPlease select Year Issue!");
}
else if (i.ShortChar01.ToUpper() =="WEEK" && String.IsNullOrEmpty(i.ShortChar02))
{
throw new Ice.BLException("DMS-DataForecast-DMS_CheckForecastPeriod: This Forecast does not have Week!\nPlease select Week!");
}
else if (i.ShortChar01.ToUpper() =="MONTH" && String.IsNullOrEmpty(i.ShortChar03))
{
throw new Ice.BLException("DMS-DataForecast-DMS_CheckForecastPeriod: This Forecast does not have Month!\nPlease select Month!");
}
}


Thanks you! Have a nice day!



