locked
Retrieved records have empty attributes in silverlight app RRS feed

  • Question

  • Hello Everyone,

    I am having difficulties with a query result in silverlight. I am using the SOAP endpoint to retrieve the system views for an entity. However, I get empty attributes in the response. It retrieves the correct amount of records, the proper id and logicalname, and the proper number of attributes, but all the attribute key/value pairs are null.

    My code looks like the following, where service is an IOrganizationService:

    private void getViewList()
            {
                ColumnSet cs = new ColumnSet();            
                cs.Columns = new System.Collections.ObjectModel.ObservableCollection<string>();
                cs.Columns.Add("name");
                cs.Columns.Add("fetchxml");
    
                FilterExpression fe = new FilterExpression();
                ConditionExpression cd = new ConditionExpression();
                cd.AttributeName = "returnedtypecode";
                cd.Operator = ConditionOperator.Equal;
                cd.Values = new System.Collections.ObjectModel.ObservableCollection<object>();
                cd.Values.Add("promx_project");
                fe.Conditions = new System.Collections.ObjectModel.ObservableCollection<ConditionExpression>();
                fe.Conditions.Add(cd);
    
                QueryExpression query = new QueryExpression
                {
                    EntityName = "savedquery",
                    ColumnSet = cs,
                    Criteria = fe
                };
    
                service.BeginRetrieveMultiple(query, (result) =>
                {
                    var response = ((IOrganizationService)result.AsyncState).EndRetrieveMultiple(result);
                    Dispatcher.BeginInvoke(new Action(
                        () =>
                        {
                            foreach (var item in response.Entities)
                            {
                                string name = null, fetchXml = null;
                                foreach (var attribute in item.Attributes)
                                {
                                    if (attribute.Key == "name") name = attribute.Value.ToString();
                                    if (attribute.Key == "fetchxml") fetchXml = attribute.Value.ToString();
                                }
                                if (name != null) viewList.Add(name, fetchXml);
                            }
                            this.viewCombo.ItemsSource = viewList.Keys;
                        }
                        )
                    );
                }, service);
            }

    The strange part is that if I use the same query synchronously from a console app, everything works fine.

    Any ideas?

    Regards,

    Adam

    Tuesday, September 16, 2014 11:42 AM

Answers