Need help to retrieve metadata
-
Wednesday, May 09, 2012 11:00 PM
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?
All Replies
-
Wednesday, May 09, 2012 11:22 PM
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
- Proposed As Answer by Dimaz Pramudya (www.xrmbits.com) Wednesday, May 09, 2012 11:22 PM
-
Wednesday, May 09, 2012 11:26 PM
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
-
Wednesday, May 09, 2012 11:28 PMAre 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
-
Wednesday, May 09, 2012 11:30 PM
It's supposed to be a silverlight web resource, but I've never used Silverlight before
-
Wednesday, May 09, 2012 11:34 PM
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
- Proposed As Answer by Dimaz Pramudya (www.xrmbits.com) Wednesday, May 09, 2012 11:38 PM
-
Wednesday, May 09, 2012 11:50 PM
Thanks for your help Dimaz. Not sure what I'm doing but I'll give it a go
-
Thursday, May 10, 2012 12:09 AM
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
-
Wednesday, September 12, 2012 10:52 AM
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!