fake-xrm-easy-js
fake-xrm-easy-js copied to clipboard
Guid values in $filter are treated as properties instead of literal values
When filtering by Guid, literal.value is undefined, since is not interpreted as a literal value by the odata parser
Ex: emails?$select=*&$filter=_regardingobjectid_value eq 2289062e-d689-2292-51d0-d85ce235a927
Entity.prototype.satisfiesFilterEq = function (filter) {
var property = this.getFilterProperty(filter);
var literal = this.getFilterLiteral(filter);
return this.attributes[property.name] === literal.value;
};
Sample unit test to reproduce:
test("$filter: eq test with Guid", done => {
context.initialize([
new Entity("email", Guid.create(), {description: 'Email Text 1', _regardingobjectid_value: "2289062e-d689-2292-51d0-d85ce235a927", other: "somevalue"}),
new Entity("email", Guid.create(), {description: 'Email Text 2', _regardingobjectid_value: "2289062e-d689-2292-51d0-d85ce235a927", other: "someothervalue"})
]);
WebApiClient.retrieveMultiple("emails?$filter=_regardingobjectid_value eq 2289062e-d689-2292-51d0-d85ce235a927", function (data) {
expect(data.value.length).toBe(2);
expect(data.value[0].description).toBe("Email Text 1");
expect(data.value[1].description).toBe("Email Text 2");
done();
});
});