public static List <Entity> RetrieveUserDashboards(IOrganizationService service)
        {
            try
            {
                var results = service.RetrieveMultiple(new QueryExpression("userform")
                {
                    ColumnSet = new ColumnSet(true),
                    Criteria  = new FilterExpression
                    {
                        Conditions =
                        {
                            new ConditionExpression("objecttypecode", ConditionOperator.Equal, "none"),
                            new ConditionExpression("type",           ConditionOperator.Equal, 0)
                        }
                    }
                });

                return(results.Entities.ToList());
            }
            catch (Exception error)
            {
                string errorMessage = CrmExceptionHelper.GetErrorMessage(error, false);
                throw new Exception("Error while retrieving user dashboards: " + errorMessage);
            }
        }
Exemplo n.º 2
0
        public static EntityMetadata RetrieveEntity(string logicalName, IOrganizationService oService)
        {
            try
            {
                RetrieveEntityRequest request = new RetrieveEntityRequest
                {
                    LogicalName   = logicalName,
                    EntityFilters = EntityFilters.Attributes | EntityFilters.Relationships
                };

                RetrieveEntityResponse response = (RetrieveEntityResponse)oService.Execute(request);

                return(response.EntityMetadata);
            }
            catch (Exception error)
            {
                string errorMessage = CrmExceptionHelper.GetErrorMessage(error, false);
                throw new Exception("Error while retrieving entity: " + errorMessage);
            }
        }