Hello,
I'm trying to query timesheet data with ordering, but the parameter OrderBy (Ascending|Descending) is not working. Below is my current PHP scripts. Thank you!
$client = new SoapClient(" https://api.clarizen.com/v1.0/Clarizen.svc?WSDL", array('trace' => 1, "cache_wsdl" => WSDL_CACHE_DISK));
// Login
$params = array(
"userName"=>"xxx",
"password"=>"xxx",
"options"=>array(
"ApplicationId"=>"app name",
"PartnerId"=>"partner id"
)
);
$response = $client->Login($params);
$responseJSON = json_encode($response);
echo $responseJSON . "<br/><br/>";
// Set SessionId
$sessionId = $response->LoginResult->SessionId;
$header = new SoapHeader(' http://clarizen.com/api';, 'Session', array("ID"=>$sessionId));
$client->__setSoapHeaders($header);
// Get Projects
$LeftStartDate = array (
"FieldName" => "ReportedDate");
$MinDate = "2012-10-01";
$RightStartDate = array (
"Value" => new SoapVar ($MinDate, XSD_DATETIME, "dateTime", " http://www.w3.org/2001/XMLSchema")));
$StartDateCondition = array (
"LeftExpression" => new SoapVar ($LeftStartDate,SOAP_ENC_OBJECT, "FieldExpression", " http://clarizen.com/api/queries"),
"Operator" => "GreaterThanOrEqual",
"RightExpression" => new SoapVar ($RightStartDate,SOAP_ENC_OBJECT, "ConstantExpression"," http://clarizen.com/api/queries")));
$LeftEndDate = array (
"FieldName" => "ReportedDate");
$MaxDate = "2013-08-01";
$RightEndDate = array (
"Value" => new SoapVar ($MaxDate, XSD_DATETIME, "dateTime", " http://www.w3.org/2001/XMLSchema")));
$EndDateCondition = array (
"LeftExpression" => new SoapVar ($LeftEndDate,SOAP_ENC_OBJECT, "FieldExpression", " http://clarizen.com/api/queries"),
"Operator" => "LessThan",
"RightExpression" => new SoapVar ($RightEndDate,SOAP_ENC_OBJECT, "ConstantExpression"," http://clarizen.com/api/queries")));
$AndCondition = array (
"Conditions" => array ( new SoapVar ( $StartDateCondition,SOAP_ENC_OBJECT, "Compare", " http://clarizen.com/api/queries" ),
new SoapVar ( $EndDateCondition,SOAP_ENC_OBJECT, "Compare", " http://clarizen.com/api/queries" )
));
$params = array(
"Fields" => array(
"ReportedBy.DisplayName",
"CreatedBy.DisplayName",
"Duration.Length",
"RegularHours",
"ReportedDate",
"LastUpdatedOn",
"WorkItem.Name",
"Comment",
"WorkItem.Billable",
" WorkItem.ProjectType.Name",
" WorkItem.Project.ProjectSize.Name",
"WorkItem.Project.ProjectManager.DisplayName",
"WorkItem.Project.Manager.DisplayName"
),
"TypeName" => "Timesheet",
"Orders" => array(
array(
"FieldName" => "ReportedDate",
"OrderBy" => "Descending"
)
),
"Where" => new SoapVar ($AndCondition, SOAP_ENC_OBJECT, "And", " http://clarizen.com/api/queries"),
"Paging" => array(
"PageNumber" => 0,
"PageSize" => 20
)
);
$request[] = new SoapVar($params, SOAP_ENC_OBJECT, "EntityQuery", " http://clarizen.com/api/queries");
$executeResponse = $client->Execute(array("request"=>$request));
$responseJSON = json_encode($executeResponse);