private void GetFormXml(string formId, out string formXml, out string entityLogicalName) { formXml = string.Empty; entityLogicalName = string.Empty; var fetchData = new { formid = formId }; var fetchXml = $@" <fetch> <entity name='systemform'> <attribute name='formxml' /> <attribute name='objecttypecode' /> <filter> <condition attribute='formid' operator='eq' value='{fetchData.formid}'/> </filter> </entity> </fetch>"; var rows = CrmService.RetrieveMultiple(new FetchExpression(fetchXml)); if (rows.Entities.Count != 1) { return; } var entity = rows.Entities[0]; formXml = entity.GetAttributeValue <string>("formxml"); entityLogicalName = entity.GetAttributeValue <string>("objecttypecode"); }
public static UserSettings GetUserSettings(CrmService service) { var query = new QueryExpression("usersettings"); query.TopCount = 1; query.ColumnSet.AllColumns = true; query.Criteria.AddCondition("systemuserid", ConditionOperator.EqualUserId); var settingsEntity = service.RetrieveMultiple(query).Entities[0]; query = new QueryExpression("timezonedefinition"); query.TopCount = 1; query.ColumnSet.AddColumn("standardname"); query.Criteria.AddCondition("timezonecode", ConditionOperator.Equal, settingsEntity["timezonecode"]); var timeZoneEntity = service.RetrieveMultiple(query).Entities[0]; var timeZoneInfo = TimeZoneInfo.FindSystemTimeZoneById(timeZoneEntity.GetAttributeValue <string>("standardname")); return(new UserSettings(settingsEntity, timeZoneInfo)); }
public static CrmModelApps GetApps(CrmService service) { var query = new QueryExpression("appmodule"); query.ColumnSet.AddColumns("uniquename"); var result = service.RetrieveMultiple(query); return(new CrmModelApps(result.Entities)); }
/// <summary> /// Gets setting of the specified user. /// </summary> /// <param name="service">The service client.</param> /// <param name="userName">The user name.</param> /// <returns></returns> /// <exception cref="NotFoundException">Thrown when user can't be found.</exception> public static UserSettings GetUserSettings(CrmService service, string userName) { var userQuery = new QueryExpression("systemuser") { ColumnSet = { AllColumns = true }, TopCount = 1 }; userQuery.Criteria.AddCondition("domainname", ConditionOperator.Equal, userName); var userEntity = service.RetrieveMultiple(userQuery); if (!userEntity.Entities.Any()) { throw new NotFoundException($"The user with domainname '{userName}' is not found!"); } var userGuid = userEntity.Entities[0]["systemuserid"]; var query = new QueryExpression("usersettings") { TopCount = 1, ColumnSet = { AllColumns = true } }; query.Criteria.AddCondition("systemuserid", ConditionOperator.Equal, userGuid); var settingsEntity = service.RetrieveMultiple(query).Entities[0]; query = new QueryExpression("timezonedefinition") { TopCount = 1 }; query.ColumnSet.AddColumn("standardname"); query.Criteria.AddCondition("timezonecode", ConditionOperator.Equal, settingsEntity["timezonecode"]); var timeZoneEntity = service.RetrieveMultiple(query).Entities[0]; var timeZoneInfo = TimeZoneInfo.FindSystemTimeZoneById(timeZoneEntity.GetAttributeValue <string>("standardname")); return(new UserSettings(settingsEntity, timeZoneInfo)); }