Need help to retrieve metadata

Foreslået svar Need help to retrieve metadata

  • 9. maj 2012 23:00
     
     

    Hi guys,

    I am trying to retrive a list of all entities and display them in a drop down box in crm 2011. Can someone please help me acheive this?

Alle besvarelser

  • 9. maj 2012 23:22
     
     Foreslået svar Har kode

    Hi Brad,

    You can use this code.

    Hope this helps.

    var serviceProxy = new OrganizationServiceProxy(new Uri("http://yourcrmserver/yourcrmorg/XRMServices/2011/Organization.svc"), null, new ClientCredentials(), null);
    
    var request = new RetrieveAllEntitiesRequest()
    {
      EntityFilters = EntityFilters.Entity,
      RetrieveAsIfPublished = true
    };
    
    var response = (RetrieveAllEntitiesResponse)_serviceProxy.Execute(request);
    
    foreach (EntityMetadata entity in response.CrmMetadata)
    {
      string entitySchemaName = entity.SchemaName;
      string entityId = entity.MetadataId.Value.ToString();
    
      // Add the entity to your dropdown list here                
    }


    Dimaz Pramudya - CRM Developer - CSG (Melbourne) www.xrmbits.com http://twitter.com/xrmbits

  • 9. maj 2012 23:26
     
     

    Thanks Dimaz,

    But how do I actually populate the dropdown with this list of entities. I'm new at this and really need some help please

  • 9. maj 2012 23:28
     
     
    Are you populating the dropdown in your custom page? Or is it the dropdown in the CRM form?

    Dimaz Pramudya - CRM Developer - CSG (Melbourne) www.xrmbits.com http://twitter.com/xrmbits

  • 9. maj 2012 23:30
     
     

    It's supposed to be a silverlight web resource, but I've never used Silverlight before

  • 9. maj 2012 23:34
     
     Foreslået svar

    From your Silverlight project, you can add new Service Reference to your CRM Server WebService URL. Eg: http://yourcrmserver/yourcrmorg/XRMServices/2011/Organization.svc

    Then, you can copy paste the above code in the load event of the Silverlight Page. What you want is to return a list of object that your Silverlight dropdown can consume.

    Please refer to this link for example on how to populate dropdownlist in Silverlight.

    http://chandradev819.wordpress.com/2010/09/21/how-to-populate-combobox-in-silverlight/



    Dimaz Pramudya - CRM Developer - CSG (Melbourne) www.xrmbits.com http://twitter.com/xrmbits

  • 9. maj 2012 23:50
     
     

    Thanks for your help Dimaz. Not sure what I'm doing but I'll give it a go

  • 10. maj 2012 00:09
     
     

    No worries Brad.

    Glad I can help. Any questions, feel free to post it here.


    Dimaz Pramudya - CRM Developer - CSG (Melbourne) www.xrmbits.com http://twitter.com/xrmbits

  • 12. september 2012 10:52
     
      Har kode

    Hi Brad,

    You can use this code.

    Hope this helps.

    var serviceProxy = new OrganizationServiceProxy(new Uri("http://yourcrmserver/yourcrmorg/XRMServices/2011/Organization.svc"), null, new ClientCredentials(), null);
    
    var request = new RetrieveAllEntitiesRequest()
    {
      EntityFilters = EntityFilters.Entity,
      RetrieveAsIfPublished = true
    };
    
    var response = (RetrieveAllEntitiesResponse)_serviceProxy.Execute(request);
    
    foreach (EntityMetadata entity in response.CrmMetadata)
    {
      string entitySchemaName = entity.SchemaName;
      string entityId = entity.MetadataId.Value.ToString();
    
      // Add the entity to your dropdown list here                
    }


    Dimaz Pramudya - CRM Developer - CSG (Melbourne) www.xrmbits.com http://twitter.com/xrmbits

    Hi,

    I need to display list of all entities(name) in option set on crm form.

    Can you please share java script for the same?

    Thanks!