I have created a custom retrieve entity response class for crm2011 so as to serialize the class. The entity response class is derived from OrganizationRequest class. Its as shown below:
public partial class RetrieveEntityRequest : OrganizationRequest
{
public RetrieveEntityRequest()
{
}
private System.Guid metadataIdField;
public System.Guid MetadataId
{
get
{
return this.metadataIdField;
}
set
{
this.metadataIdField = value;
}
}
public EntityFilters EntityFilters { get; set; }
public string LogicalName { get; set; }
public bool RetrieveAsIfPublished { get; set; }
}
Now when i run the code shown below
using (OrganizationServiceProxy serviceProxy = new OrganizationServiceProxy(OrganizationUri, HomeRealmUri, Credentials, null))
{
try
{
serviceProxy.EnableProxyTypes();
request = new CrmUtilities.RetrieveEntityRequest();
request.LogicalName=entityName;
request.EntityFilters = EntityFilters.Entity;
request.RequestName = requestName;
//Execute Request
retrieveEntityResponse = (CrmUtilities.RetrieveEntityResponse)serviceProxy.Execute(request);
}
catch (System.Web.Services.Protocols.SoapException ex)
{
throw ex;
}
catch (Exception ex)
{
throw ex;
}
}
It says that MetadataId which is a required field is missing.The exception thrown is OrganizationServiceFault was caught //Required field 'MetadataId' is missing. How do i create a metadataId for this custom object in this case?