Adam Harkus
Adam Harkus

Reputation: 2210

SAPUI5 using OR in filterOperator

I need a filter condition where....

StartDate <= effectiveFrom OR StartDate <= effectiveFrom + 7 days.

How do I add an OR statment to the below code?

filters: [
    new Filter("ShopId", FilterOperator.EQ, that.sitId),
    new Filter("CategoryId", FilterOperator.EQ, "S"),
    new Filter("ApprovalId", FilterOperator.EQ, "3"),
    new Filter("StartDate", FilterOperator.LE, moment(new Date(effectiveFrom)).toDate()),

Upvotes: 0

Views: 404

Answers (1)

Ashish Patil
Ashish Patil

Reputation: 1742

var f1 = new Filter("StartDate", FilterOperator.LE, moment(new Date(effectiveFrom)).toDate());
var f2 = new Filter("StartDate", FilterOperator.LE, moment(new Date(effectiveFrom)).add(7,'days').toDate());
var filter =  new sap.ui.model.Filter({
    filters: [f1,f2],
    and: false
  })

Upvotes: 1

Related Questions