locked
Getting accounts from the view RRS feed

  • Question

  • So I am building a web resource in CRM 2011 that has a bing map control and I want it to display the accounts from the currently selected view. So when the user navigates to the accounts page, the Active Accounts View is displayed by default. I want to be able to get the accounts based on the view that the user has selected using javascript so that I can add pushpins for each account. I know that I can get the view id and view type from the querystring, but how do I get the actual accounts from the view?
    Monday, April 4, 2011 5:11 PM

Answers

  • A view of CRM is made up of LayoutXml and a FetchXml based query. You need to get the fetchXml which will actually hold the query criteria configured for that view. Once you have the fetchxml, it can be altered to return the AccountId, name, Address columns, etc and you'll get a collection of all those 300 accounts

     

    How to retrieve FetchXml of a view (SavedQuery) (just putting hints, you may dig up SDK for details)

    ... ColumnSet = new ColumnSet("savedqueryid", "name", "querytype", "isdefault", "returnedtypecode", "isquickfindquery"),
     ... RetrieveMultipleRequest retrieveSavedQueriesRequest = new RetrieveMultipleRequest { Query = mySavedQuery }; 
    RetrieveMultipleResponse retrieveSavedQueriesResponse = (RetrieveMultipleResponse)_serviceProxy.Execute(retrieveSavedQueriesRequest); 
    DataCollection<Entity> savedQueries = retrieveSavedQueriesResponse.EntityCollection.Entities;

    How to retrieve data using fetchXml

    EntityCollection result = _serviceProxy.RetrieveMultiple(new FetchExpression(fetchXml)); 

     

     


    If this post answers your question, please click "Mark As Answer"



    Tuesday, April 5, 2011 11:13 PM

All replies

  • Hello Mike,

    You need to iterate through the grid's rows. Inspect the grid (F12 in Internet Explorer) to find out exactly what elements you need to work with.


    Cornel Croitoriu - Senior Software Developer & Entrepreneur

    If this post answers your question, please click "Mark As Answer" on the post and "Mark as Helpful"

    Biz-Forward.comCroitoriu.NET

    Tuesday, April 5, 2011 6:49 AM
  • That is a good idea, but what if my grid is set to display only 25 records per page, but I have 300 records. I would like to be able to show all these records, even if my results are paginated.
    Tuesday, April 5, 2011 4:09 PM
  • A view of CRM is made up of LayoutXml and a FetchXml based query. You need to get the fetchXml which will actually hold the query criteria configured for that view. Once you have the fetchxml, it can be altered to return the AccountId, name, Address columns, etc and you'll get a collection of all those 300 accounts

     

    How to retrieve FetchXml of a view (SavedQuery) (just putting hints, you may dig up SDK for details)

    ... ColumnSet = new ColumnSet("savedqueryid", "name", "querytype", "isdefault", "returnedtypecode", "isquickfindquery"),
     ... RetrieveMultipleRequest retrieveSavedQueriesRequest = new RetrieveMultipleRequest { Query = mySavedQuery }; 
    RetrieveMultipleResponse retrieveSavedQueriesResponse = (RetrieveMultipleResponse)_serviceProxy.Execute(retrieveSavedQueriesRequest); 
    DataCollection<Entity> savedQueries = retrieveSavedQueriesResponse.EntityCollection.Entities;

    How to retrieve data using fetchXml

    EntityCollection result = _serviceProxy.RetrieveMultiple(new FetchExpression(fetchXml)); 

     

     


    If this post answers your question, please click "Mark As Answer"



    Tuesday, April 5, 2011 11:13 PM