0
votes

I have a CRM function that returns the attribute types of all attributes in a entity. My problem is all though this same method has worked in the past it's now throwing this error regardless of the entity I pass in to it.

There was an error while trying to deserialize parameter http://schemas.microsoft.com/xrm/2011/Contracts/Services:ExecuteResult

Here is my code, I'm passing in the "account" entity.

public string GetFieldType(IOrganizationService svc, string entity, string fieldName)
        {
            RetrieveEntityRequest request = new RetrieveEntityRequest()
            {
                EntityFilters = EntityFilters.Attributes,
                LogicalName = entity
            };

            RetrieveEntityResponse response = (RetrieveEntityResponse)svc.Execute(request);
            string type = "";
            foreach (AttributeMetadata attribute in response.EntityMetadata.Attributes)
            {
                if (attribute.LogicalName == fieldName)
                { type = attribute.AttributeType.ToString(); }
            }

            return type;
        }
1
Are you using early bound entities?James Wood

1 Answers

0
votes

If the code was working before, and it's not now, odds are that it is not a problem with your code. Most likely your svc.Execute is failing. Have you changed how your IOrganizationService is being created? Are you running as a user with rights to query the CRM instance? If all of these things check out, then try turning on server side tracing through the diagnostic tool.