Post

1 follower Follow
0
Avatar

Trouble with returning things created after a certain date

I want to pull all items with a certain status, on or after a certain date. I hard coded a date for testing, but I got a return of a date before that date. Here's my WHERE statement:

 

$createdOn = "2014-04-01";

                        $LeftDate = array (

                    "FieldName" => "CreatedOn");

            $RightDate = array (

                    "Value" => new SoapVar ($createdOn, XSD_DATETIME, "dateTime", "http://www.w3.org/2001/XMLSchema"));

            $DateCondition = array (

                    "LeftExpression" => new SoapVar ($LeftDate,SOAP_ENC_OBJECT, "FieldExpression", "http://clarizen.com/api/queries"),

                    "Operator" => "GreaterThanOrEqual",

                    "RightExpression" => new SoapVar ($RightDate,SOAP_ENC_OBJECT, "ConstantExpression","http://clarizen.com/api/queries"));

        $Where = new SoapVar ($DateCondition,SOAP_ENC_OBJECT, "Compare", "http://clarizen.com/api/queries");   

 

 

And here is one of the work items that got returned:

                  [1]=>

                  object(stdClass)#1072 (2) {

                    ["FieldName"]=>

                    string(8) "WorkItem"

                    ["Value"]=>

                    object(stdClass)#1073 (2) {

                      ["Id"]=>

                      object(stdClass)#1074 (2) {

                        ["TypeName"]=>

                        string(4) "Task"

                        ["Value"]=>

                        string(32) "f3d5307c193d499f997831480555bddd"

                      }

                      ["Values"]=>

                      object(stdClass)#1075 (1) {

                        ["FieldValue"]=>

                        array(3) {

                          [0]=>

                          object(stdClass)#1076 (2) {

                            ["FieldName"]=>

                            string(4) "Name"

                            ["Value"]=>

                            string(49) "TUV SUD | PPC Report | Edits from Amanda's Review"

                          }

                          [1]=>

                          object(stdClass)#1077 (2) {

                            ["FieldName"]=>

                            string(9) "CreatedOn"

                            ["Value"]=>

                            string(26) "2014-03-03T15:55:21.725308"

                          }

                          [2]=>

                          object(stdClass)#1078 (2) {

                            ["FieldName"]=>

                            string(12) "C_WorkStatus"

                            ["Value"]=>

                            object(stdClass)#1079 (2) {

                              ["Id"]=>

                              object(stdClass)#1080 (2) {

                                ["TypeName"]=>

                                string(20) "C_WorkItemWorkStatus"

                                ["Value"]=>

                                string(8) "On Track"

                              }

                              ["Values"]=>

                              object(stdClass)#1081 (0) {

                              }

                            }

                          }

 

 

I know the ate filter is working mostly, I switched it to LessThanOrEqual and got items before it as expected. I just don't know why something from 3/3/14 showed up. What'd I do wrong? :)

 

Jeff

 

 

Marketing Mojo IT Answered

Please sign in to leave a comment.

7 comments

0
Avatar

Here is the whole thing I'm sending to the API client: (Is it because I'm using the ResourceLink typename?)

 

$Fields = array(

                                'Resource.UserName',

                                'WorkItem.Name' ,

                                'WorkItem.CreatedOn',

                                'WorkItem.C_WorkStatus');

                

                $Paging = NULL;

                

                

                $createdOn = "2014-04-01";

                        $LeftDate = array (

                    "FieldName" => "CreatedOn");

            $RightDate = array (

                    "Value" => new SoapVar ($createdOn, XSD_DATETIME, "dateTime", "http://www.w3.org/2001/XMLSchema"));

            $DateCondition = array (

                    "LeftExpression" => new SoapVar ($LeftDate,SOAP_ENC_OBJECT, "FieldExpression", "http://clarizen.com/api/queries"),

                    "Operator" => "GreaterThanOrEqual",

                    "RightExpression" => new SoapVar ($RightDate,SOAP_ENC_OBJECT, "ConstantExpression","http://clarizen.com/api/queries"));

        $Where = new SoapVar ($DateCondition,SOAP_ENC_OBJECT, "Compare", "http://clarizen.com/api/queries");    

        

        $clarizenReturn = $clarizenAPI->getList('RegularResourceLink', $Fields , $Paging, $Where);

Marketing Mojo IT 0 votes
Comment actions Permalink
0
Avatar

Hi Jeff.

To start with, you may note the condition refers to the CreatedOn of the RegularResourceLink (the resource link creation time) while the result field is WorkItem.CreatedOn (the work item creation time).

Obviously resource link's creation time can be later than the work item's, so you'll need to change the condition to refer to the work item's creation time, or add the resource link's creation time to the result.

Hope this helps,

Ophir

 

Ophir Kenig 0 votes
Comment actions Permalink
0
Avatar

I get it, but I don't know how to make the condition refer to the WorkItem.CreatedOn instead of theResourceLinks's  CreatedOn.How do I do that? I think I tried WorkItem.CreatedOn and it yelled at me. :)

 

Jeff

Marketing Mojo IT 0 votes
Comment actions Permalink
0
Avatar

Ophir,

 

Thanks to your help, I'm much closer. Now, I have two sets of conditions and I'd like to return items if the first set is true OR the second set is true. I'm having trouble figuring out how to nest the conditions. Basically, the conditions are:

set1(100 days ago > StartDate > today AND PlannedRevenue > 0)

OR 

set1(100 days ago > DueDate > today AND PlannedRevenue > 0)

 

$AndCondition = array (

"Conditions" => array ( new SoapVar ($Expression, SOAP_ENC_OBJECT, "Compare", "http://clarizen.com/api/queries" ),

new SoapVar ($Expression2,SOAP_ENC_OBJECT, "Compare", "http://clarizen.com/api/queries"),

new SoapVar ($Expression5,SOAP_ENC_OBJECT, "Compare", "http://clarizen.com/api/queries")

));

$AndCondition2 = array (

"Conditions" => array ( new SoapVar ($Expression3, SOAP_ENC_OBJECT, "Compare", "http://clarizen.com/api/queries" ),

new SoapVar ($Expression4, SOAP_ENC_OBJECT, "Compare", "http://clarizen.com/api/queries"),

new SoapVar ($Expression5, SOAP_ENC_OBJECT, "Compare", "http://clarizen.com/api/queries")

));

 

What I need is to return if AndCondition OR AndCondition2. Help!

 

Thanks!

 

Jeff

Marketing Mojo IT 0 votes
Comment actions Permalink
0
Avatar

This is how I tried to construct the rest of hte query:

$OrCondition = array ( "Conditions" => array (

      new SoapVar ($AndCondition, SOAP_ENC_OBJECT, "And", "http://clarizen.com/api/queries"),

      new SoapVar ($AndCondition2, SOAP_ENC_OBJECT, "And", "http://clarizen.com/api/queries")));

$Where = new SoapVar ($OrCondition, SOAP_ENC_OBJECT, "Or", "http://clarizen.com/api/queries");

$clarizenReturn = $clarizenAPI->getList('GroupProjectLink', $Fields , $Paging, $Where);

Marketing Mojo IT 0 votes
Comment actions Permalink
0
Avatar

Hi Jeff.

Just looking at your code, it seems to be the right way. Did it work or you had issues with it?

If you did, please send the full code and the error if any.

Hope this helps,

Ophir

Ophir Kenig 0 votes
Comment actions Permalink