Here’s my code for looking up whether a user belongs to a security group in form customisation:
private bool UserBelongsToProdSupGroup()
{
EpiDataView edv = (EpiDataView) this.oTrans.EpiDataViews["CallContextClientData"];
string userID = edv.dataView[0]["CurrentUserId"].ToString();
try
{
UserFileAdapter adapterUserFile = new UserFileAdapter(this.oTrans);
adapterUserFile.BOConnect();
bool result = adapterUserFile.GetByID(userID);
if (result)
{
if (adapterUserFile.UserFileData.UserFile[0]["GroupList"].ToString().IndexOf("_PR_Sup") != -1)
{
//MessageBox.Show("User belongs to ProdSup Group");
return true;
}
}
adapterUserFile.Dispose();
}
catch (System.Exception ex)
{
ExceptionBox.Show(ex);
}
return false;
}