XrmQuery.retrieveMultiple(x => x.accounts)
.select(x =>[ x.name])
.filter(x => Filter.equals(x.primarycontactid_guid, Filter.makeGuid("test")))
.execute(records => function () { }, function (error)
{
alert(error);
});
XrmQuery.REST.retrieveMultipleRecords(x => x.Account)
.select(x => [x.Name])
.filter(x => Filter.REST.equals(x.PrimaryContactId.Id, Filter.REST.makeGuid("test")))
.execute(records => function ()
{
alert(records);
},
function (error)
{
alert(error);
},null);
I have two queries - first one using webapi and second one - using rest endpoint.
Second one works fine but the first one returns error:
{ "error":{ "code":"","message":"Could not find a property named 'primarycontactid_guid' on type 'Microsoft.Dynamics.CRM.account'.","innererror":{ "message":"Could not find a property named 'primarycontactid_guid' on type 'Microsoft.Dynamics.CRM.account'.","type":"Microsoft.OData.Core.ODataException","stacktrace":" w Microsoft.OData.Core.UriParser.Parsers.EndPathBinder.GeneratePropertyAccessQueryForOpenType(EndPathToken endPathToken, SingleValueNode parentNode)\r\n w Microsoft.OData.Core.UriParser.Parsers.EndPathBinder.BindEndPath(EndPathToken endPathToken)\r\n w Microsoft.OData.Core.UriParser.Parsers.MetadataBinder.Bind(QueryToken token)\r\n w Microsoft.OData.Core.UriParser.Parsers.BinaryOperatorBinder.GetOperandFromToken(BinaryOperatorKind operatorKind, QueryToken queryToken)\r\n w Microsoft.OData.Core.UriParser.Parsers.BinaryOperatorBinder.BindBinaryOperator(BinaryOperatorToken binaryOperatorToken)\r\n w Microsoft.OData.Core.UriParser.Parsers.MetadataBinder.Bind(QueryToken token)\r\n w Microsoft.OData.Core.UriParser.Parsers.FilterBinder.BindFilter(QueryToken filter)\r\n w Microsoft.OData.Core.UriParser.ODataQueryOptionParser.ParseFilterImplementation(String filter, ODataUriParserConfiguration configuration, IEdmType elementType, IEdmNavigationSource navigationSource)\r\n w Microsoft.OData.Core.UriParser.ODataQueryOptionParser.ParseFilter()\r\n w System.Web.OData.Query.FilterQueryOption.get_FilterClause()\r\n w Microsoft.Crm.Extensibility.OData.DataQueryOptionsConverter.SetFilterExpression(QueryExpression qe, FilterQueryOption filterQueryOption)\r\n w Microsoft.Crm.Extensibility.OData.QueryOptionsConverterBase4.GetQueryExpression(ODataQueryOptions queryOptions, String edmEntityName, CrmODataExecutionContext context)\r\n w Microsoft.Crm.Extensibility.OData.CrmODataServiceDataProvider.RetrieveEdmEntityCollection(CrmODataExecutionContext context, String entityCollectionName, String castedEntityName, ODataQueryOptions queryOptions)\r\n w Microsoft.Crm.Extensibility.OData.EntityController.GetEntitySetInternal(String entitySetName, String castEntityName, CrmODataExecutionContext context, CrmEdmEntityObjectCollection crmEdmEntityObjectCollection, ODataQueryOptions queryOptions)\r\n w Microsoft.Crm.Extensibility.OData.EntityController.GetEntitySet(String entitySetName)\r\n w lambda_method(Closure , Object , Object[] )\r\n w System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass10.<GetExecutor>b__9(Object instance, Object[] methodParameters)\r\n w System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ExecuteAsync(HttpControllerContext controllerContext, IDictionary2 arguments, CancellationToken cancellationToken)\r\n--- Koniec \u015bladu stosu z poprzedniej lokalizacji, w kt\u00f3rej wyst\u0105pi\u0142 wyj\u0105tek ---\r\n w System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n w System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n w System.Web.Http.Controllers.ApiControllerActionInvoker.<InvokeActionAsyncCore>d__0.MoveNext()\r\n--- Koniec \u015bladu stosu z poprzedniej lokalizacji, w kt\u00f3rej wyst\u0105pi\u0142 wyj\u0105tek ---\r\n w System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n w System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n w System.Web.Http.Controllers.ActionFilterResult.<ExecuteAsync>d__2.MoveNext()\r\n--- Koniec \u015bladu stosu z poprzedniej lokalizacji, w kt\u00f3rej wyst\u0105pi\u0142 wyj\u0105tek ---\r\n w System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n w System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n w System.Web.Http.Dispatcher.HttpControllerDispatcher.<SendAsync>d__1.MoveNext()" } } }
I'm using Dynamics CRM 2016 and tested it with api 8.0 and 8.1`
Generated request url is
v8.1/accounts?$select=name&$filter=primarycontactid_guid%20eq%20test