[SalesForce] SSJS Complex filter with more than one propertie

I currently have a 4 column table with: Product, Count, Date, BusinessUnit

Product, Count, Date, BusinessUnit
Mouse, 100, 2014-05-1, StoreBB
Mouse, 120, 2014-06-01, StoreTBB
Keyboard, 130, 2014-06-21, StoreBB
Keyboard, 10, 2014-06-01, StoreTBB

Using a SSJS complex filter, I wanna be able to select those who purchased a mouse in May from BusinessUnit StoreTBB. The sample below filters the date and BusinessUnit fine, but when I try to add the Product property on the RightOperand I get errors.

 var complexfilterBB = {

                LeftOperand:{
                    Property:"Date",
                    SimpleOperator:"greaterThanOrEqual",
                    Value: "2014-05-01"
                },
                LogicalOperator:"AND",
                RightOperand:{
                    Property:"Date",
                    SimpleOperator:"lessThanOrEqual",
                    Value: "2014-06-30",
                    Property: "BusinessUnit", 
                    SimpleOperator: "equals", 
                    Value: "StoreTBB"
                }

    };

How can I perform a complex filter with a date range and two or more properties?

Best Answer

Will something like this work?:

var complexfilterBB = {

            LeftOperand:{
                Property:"Date",
                SimpleOperator:"greaterThanOrEqual",
                Value: "2014-05-01"
            },
            LogicalOperator:"AND",
            RightOperand:{
                LeftOperand:{
                    Property:"Date",
                    SimpleOperator:"greaterThanOrEqual",
                    Value: "2014-05-01"
                },
                LogicalOperator:"AND",
                RightOperand:{
                    Property:"Date",
                    SimpleOperator:"lessThanOrEqual",
                    Value: "2014-06-30",
                    Property: "BusinessUnit", 
                    SimpleOperator: "equals", 
                    Value: "StoreTBB"
                }
            }

};

If not, you may need to work with the ComplexFilterPart object to build these parts together as API Objects.

Related Topic