sp-client-custom-fields
sp-client-custom-fields copied to clipboard
Issue with startsWith and substringof filters in PropertyFieldSPListQueryHost
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?