Question

Am developing a windows form which resembles the look up view on CRM 2011. For this I do the following 1) Show the relevant records (of opportunity entity) in a datagirdview 2) Also have a dropdownlist that binds to the views (View.Name) to allow the user to choose the view according to which i intend to change the filter on my datagrid view.

Am stuck with the following.Am able to retrieve the views on the "Opporutunity" entity using the following code

ConditionExpression condition1 = new ConditionExpression()
                    {
                        AttributeName = "querytype",
                        Operator = ConditionOperator.Equal,
                        Values = { 0 }
                    };
                    ConditionExpression condition2 = new ConditionExpression()
                    {
                        AttributeName = "returnedtypecode",
                        Operator = ConditionOperator.Equal,
                        Values = { Opportunity.EntityTypeCode }
                    };
                    FilterExpression filter = new FilterExpression();
                    filter.Conditions.Add(condition1);
                    filter.Conditions.Add(condition2);

                    QueryExpression queryToRetrieveViews = new QueryExpression
                    {
                        ColumnSet = new ColumnSet("savedqueryid", "name", "querytype", "isdefault", "returnedtypecode", "isquickfindquery"),
                        EntityName = SavedQuery.EntityLogicalName,
                        Criteria = filter
                    };
                    RetrieveMultipleRequest retrieveSavedViewsRequest = new RetrieveMultipleRequest { Query = queryToRetrieveViews };

                    RetrieveMultipleResponse retrieveSavedViewsResponse = (RetrieveMultipleResponse)crm.Execute(retrieveSavedViewsRequest);

                    DataCollection<Entity> savedViews = retrieveSavedViewsResponse.EntityCollection.Entities;

                    foreach (Entity ent in savedViews){...}

I did a quick watch but am unable to find the attribute that has the filter conditions as present in CRM. I mean what i intend to look at is something like this sayfor e.g. open opportunities the filter would be "statecode=0". Is it possible to fetch the associated filters? -sorry by Associated filters i mean filters of the view

Was it helpful?

Solution

You can filter by whatever attribute you'd like so I'm not sure what you mean by the associated filters. If you mean the filter of the actual view you won't find it. Views are stored in XML, so you'll have to retrieve the the FetchXML for the saved view and parse the XML to see it's filter.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top