Dynamics CRM Plugin 獲取當前使用者語言
阿新 • • 發佈:2018-11-27
1033為英語,2052為中文
public static int? GetCurrentUserLanguageId(IOrganizationService service, Guid userid) { QueryExpression mySavedQuery = new QueryExpression { ColumnSet = new ColumnSet("systemuserid", "uilanguageid"), EntityName = "usersettings", Criteria = new FilterExpression() { FilterOperator = Microsoft.Xrm.Sdk.Query.LogicalOperator.And, Conditions = { new ConditionExpression { AttributeName = "systemuserid", Operator = ConditionOperator.Equal, Values = {userid} } } } }; EntityCollection ec = service.RetrieveMultiple(mySavedQuery); if (ec != null && ec.Entities != null && ec.Entities.Count > 0 && ec.Entities[0].Contains("uilanguageid")) { return (int)(ec.Entities[0]["uilanguageid"]); } else { return null; } }