locked
Associated View Columns in a custom .aspx page RRS feed

  • Question

  • We have a requirement where we want to display all the Activities of an Account and all its related Contacts on page. Without having to go through each Contact and seeing it's activities one by one and also dont want to use Advanced find.

    My approach to the above task was to create a custom .aspx page which will look exactly like a CRM view and add a new left nav bar item to an account in isv.config.

    My problem is How can I get which columns are displayed in the system Associated view from the Metadata service so that I can show dynamically only those fields in my custom .aspx view as well.

    Thanks for your help in advance


    MSCRM 3.0 Developer
    Wednesday, June 16, 2010 8:19 AM

Answers

  • Hi for this u don't have to use MetaDatawebservice, u have to reterive the "SavedQuery" entity(This is the entity that is used for the views) using either QueryByAttribute or if you have the Guid, directly from crmService.Reterive() method using the CRMWebservice.asmx webservice.

    columnsetxml Gets or sets the definition of the columns included in the view.

    SavedQuery Represents a stored database query against the logical database.

    This will give you the actual columns that are included in teh view.

    I think for User Defined View, "UserQuery" class is used.

    Represents a saved database query that is owned by a user.

    For a list of methods and messages that operate on this class, it also has the same property.

    columnsetxml Gets or sets the definition of the columns included in the view.


    Muhammad Ali Khan
    http://malikhan.wordpress.com
    Wednesday, June 16, 2010 8:48 AM

All replies

  • Hi for this u don't have to use MetaDatawebservice, u have to reterive the "SavedQuery" entity(This is the entity that is used for the views) using either QueryByAttribute or if you have the Guid, directly from crmService.Reterive() method using the CRMWebservice.asmx webservice.

    columnsetxml Gets or sets the definition of the columns included in the view.

    SavedQuery Represents a stored database query against the logical database.

    This will give you the actual columns that are included in teh view.

    I think for User Defined View, "UserQuery" class is used.

    Represents a saved database query that is owned by a user.

    For a list of methods and messages that operate on this class, it also has the same property.

    columnsetxml Gets or sets the definition of the columns included in the view.


    Muhammad Ali Khan
    http://malikhan.wordpress.com
    Wednesday, June 16, 2010 8:48 AM
  • Muhammad,

    Thanks a lot that worked great for me. Following what the code looks like to retrieve it

    //Initialise CRM Authentication Token
    CrmSdk.CrmAuthenticationToken token = new CrmSdk.CrmAuthenticationToken();
    token.AuthenticationType = 0;
    //Retrieve CRM Organisation from custom app's web.config
    token.OrganizationName = System.Configuration.ConfigurationManager.AppSettings["CrmOrganisation"];
    
    //Initialise CRM Service
    CrmSdk.CrmService _service = new CrmSdk.CrmService();
    //Retrieve CRM Service URL from custom app's web.config
    _service.Url = System.Configuration.ConfigurationManager.AppSettings["CrmSdk.CrmServiceWsdl"];
    _service.CrmAuthenticationTokenValue = token;
    _service.Credentials = System.Net.CredentialCache.DefaultCredentials;
    
    //Retrieve SavedQuery
    savedquery sq = (savedquery)_service.Retrieve(EntityName.savedquery.ToString(), new Guid("{00000000-0000-0000-00AA-000010001200}"), new AllColumns());
    
    txtColumnSetXML.Text = "Column Set= " + sq.columnsetxml + " LayoutXML= " + sq.layoutxml;

     


    MSCRM Developer
    Wednesday, June 16, 2010 9:54 AM