Skip to content

Issue with startsWith and substringof filters in PropertyFieldSPListQueryHost #41

@wilecoyotegenius

Description

@wilecoyotegenius

There is an issue with generating filters for startsWith and substringof operators in PropertyFieldSPListQueryHost.
All fiters are generated in the form of Field operator 'value' whereas for startsWith it should be startswith(Field,'value') and for substringOf should be substringof('value',Field).

Basically, this part of saveQuery:

    queryUrl += this.state.filters[i].field;
    queryUrl += "%20";
    queryUrl += this.state.filters[i].operator;
    queryUrl += "%20'";
    queryUrl += this.state.filters[i].value;
    queryUrl += "'";

should be changed to:

if (this.state.filters[i].operator === "startswith") {  
    queryUrl += this.state.filters[i].operator;  
    queryUrl += "(";   
    queryUrl += this.state.filters[i].field;
    queryUrl += ",'";
    queryUrl += this.state.filters[i].value;
    queryUrl += "')";
} else if (this.state.filters[i].operator === "substringof") {
    queryUrl += this.state.filters[i].operator;
    queryUrl += "('";
    queryUrl += this.state.filters[i].value;
    queryUrl += "',";
    queryUrl += this.state.filters[i].field;
    queryUrl += ")";
} else {
    queryUrl += this.state.filters[i].field;
    queryUrl += "%20";
    queryUrl += this.state.filters[i].operator;
    queryUrl += "%20'";
    queryUrl += this.state.filters[i].value;
    queryUrl += "'";
}

I'd be happy to fix this issue. Do you accept PRs?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions