Skip to content
This repository has been archived by the owner on Jan 20, 2024. It is now read-only.

Complex and Simple FIlter #141

Open
cosmok opened this issue May 16, 2019 · 10 comments
Open

Complex and Simple FIlter #141

cosmok opened this issue May 16, 2019 · 10 comments

Comments

@cosmok
Copy link

cosmok commented May 16, 2019

HI,

I am trying to achieve the equivalent of this SQL filter bit:

("SubscriberKey" IS NOT NULL)
 AND 
("EventDate" > SOME_DATE AND "EventDate" < SOME_OTHER_DATE)

Tried this:

$filter = [
               "LeftOperand" => [
                        'LeftOperand' => ['Property' => 'EventDate','SimpleOperator' => 'greaterThan','Value' => '2019-01-24T00:00:00'],
                        'LogicalOperator' => 'AND',
                        'RightOperand' => ['Property' => 'EventDate','SimpleOperator' => 'lessThan','Value' => '2019-01-24T17:19:00']
                    ],  
                "LogicalOperator" => "AND",
                'RightOperand' => ['Property' => 'SubscriberKey', 'SimpleOperator' => 'isNotNull'],
            ]; 

but, getting an error:

Uncaught SoapFault exception: [Client] SOAP-ERROR: Encoding: object has no 'Property' property in /home/test/workspace/mc/vendor/salesforce-mc/fuel-sdk-php/src/ET_Get.php:78
@garek007
Copy link

What object are you trying to filter?

@cosmok
Copy link
Author

cosmok commented May 16, 2019

@garek007 Sent object

@garek007
Copy link

@cosmok
Copy link
Author

cosmok commented May 17, 2019

@garek007
Copy link

My bad

@garek007
Copy link

garek007 commented May 17, 2019

I'm not sure the Fuel SDK is set up to accept 3 parameters. I was able to get it to work by changing line 61 of ET_Get.php to
$cfp->LeftOperand = new SoapVar($filter["LeftOperand"], SOAP_ENC_OBJECT, 'ComplexFilterPart', "http://exacttarget.com/wsdl/partnerAPI");
(changed SimpleFilterPart to ComplexFilterPart)

I encountered this before and you have to create soap objects and nest complex filters. So after doing that, this worked for me.


        $cfp = new stdClass();
        $cfp->LeftOperand = new SoapVar(['Property' => 'EventDate','SimpleOperator' => 'greaterThan','Value' => '2019-01-24T00:00:00'], SOAP_ENC_OBJECT, 'SimpleFilterPart', "http://exacttarget.com/wsdl/partnerAPI");
        $cfp->RightOperand = new SoapVar(['Property' => 'EventDate','SimpleOperator' => 'lessThan','Value' => '2019-06-24T17:19:00'], SOAP_ENC_OBJECT, 'SimpleFilterPart', "http://exacttarget.com/wsdl/partnerAPI");       
        $cfp->LogicalOperator = "AND";
        //$retrieveRequest["Filter"] = new SoapVar($cfp, SOAP_ENC_OBJECT, 'ComplexFilterPart', "http://exacttarget.com/wsdl/partnerAPI");


  $get->filter = [
               "LeftOperand" => $cfp,  
                "LogicalOperator" => "AND",
                'RightOperand' => ['Property' => 'SubscriberKey', 'SimpleOperator' => 'equals','Value'=>'[email protected]'],
            ]; 

Obviously this is not a fix, but perhaps you can create your own ET_Get Class. That's probably what I'll do.

@cosmok
Copy link
Author

cosmok commented May 20, 2019

Wow, thanks @garek007

@garek007
Copy link

No worries @cosmok I needed to figure it out too for my own purposes. When I get around to updating the class, I can post it here.

@garek007
Copy link

garek007 commented Aug 5, 2019

@cosmok were you ever able to get this to work? Because I haven't looked at it since this post and now it's no longer working for me.

@garek007
Copy link

garek007 commented Aug 5, 2019

@cosmok nevermind, I realized why. I ended up updating ET_Get.php in my forked repo. I'm going to see if they want to merge it. It takes an array in the way that you initially posted.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants