fake-xrm-easy-js icon indicating copy to clipboard operation
fake-xrm-easy-js copied to clipboard

Guid values in $filter are treated as properties instead of literal values

Open jordimontana82 opened this issue 4 years ago • 1 comments

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;
};

jordimontana82 avatar Oct 01 '19 13:10 jordimontana82

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();
    });
});

jordimontana82 avatar Jan 28 '20 02:01 jordimontana82