locked
Possible to get fields names from CrmSdk? RRS feed

  • Question

  • Hi,

    I know I can use CrmSdk.

     

    EntityName.customentity.ToString() to retreive the name of a custom entity. Is there a similar method to get the individual field names of custom entities?

    Thanks in advance!

    Wednesday, April 28, 2010 4:05 PM

Answers

  • I think you would have to use the metadata service, similar but not the same as the CrmService (CrmSdk).
    Wednesday, April 28, 2010 6:13 PM

All replies

  • Custom entity's name wouldn't be in EntityName enum. EntityName enum is designed for system entities. 

    So you should simply use the entity's name in string, such as "new_myentity".

    EntityName enum is nothing fancy, it is simply a static list of all out-of-box entities. 

    Hope this helps. 


    Daniel Cai | http://danielcai.blogspot.com
    Wednesday, April 28, 2010 4:56 PM
  • I should clarify by pointing out that EntityName enum does seem to contain all of my custom entities in the Reference.cs proxy file generated by my web reference.

    Again, has anybody come up with a slick way of getting the field names of custom entities from Reference.cs, perhaps similar to how you can get custom entity names from the EntityName enum?

    Thanks in advance!

    Wednesday, April 28, 2010 5:50 PM
  • Maybe you have multi-organization, and you connected to a CRM organization with no customization when you added web reference? 

    If you have web reference in place, you should be able to do the following:

    new_myentity myentity = new new_myentity();
    myentity.new_myattribute = "blah blah";
    
    I would assume this is what you are looking for. 


    Daniel Cai | http://danielcai.blogspot.com
    Wednesday, April 28, 2010 6:00 PM
  • In case you are on multi-organization installation, you may refer to http://msdn.microsoft.com/en-us/library/cc151015.aspx and add web reference in the following format:

    http://<servername[:port]>/mscrmservices/2007/crmservice.asmx?WSDL&uniquename=organizationName


    Daniel Cai | http://danielcai.blogspot.com
    Wednesday, April 28, 2010 6:06 PM
  • I think you would have to use the metadata service, similar but not the same as the CrmService (CrmSdk).
    Wednesday, April 28, 2010 6:13 PM