Hello Team,
Below is my code to get all the task and subtask of all the projects from my Clarizen. The code is working, however when I crosschecked it is not returning me all the task/sub-task. Morever comments(discussion) are not fetched from this script.
Requirement:
1. Get all the task and subtask of all the projects irrespective of the status.
2. Get the Comments(Discussion) of each of the task if there any.
Please assist me with this on URGENT priority.
============================================================
$request = array();
$params = array(
'userName' => '***',
'password' => '****'
);
$soapUrl = 'https://api.clarizen.com/v1.0/Clarizen.svc?WSDL';
$soapApiUrl = 'http://clarizen.com/api';
$soapConfig = array('exceptions' => 1);
$client = new SoapClient($soapUrl, $soapConfig);
//Login using the credentials above
$response = $client->Login($params);
$sessionId = $response->LoginResult->SessionId;
$userId = $response->LoginResult->UserId;
//Create a SOAP header containing the session ID for future requests
$header = new SoapHeader($soapApiUrl, 'Session', array("ID"=>$sessionId));
$client->__setSoapHeaders($header);
//Create a Query object
$userQuery = new stdClass();
//Set the name of the entity type you are querying
$userQuery->TypeName = 'Task';
//Select the fields you want retrieved from that entity
$userQuery->Fields = array('Name','Project.Name', 'Parent.Name', 'StartDate',
'DueDate', 'Duration', 'State', 'Manager.Email', 'TrackStatus',
'Priority', 'CreatedOn', 'LastUpdatedOn', 'Description',
'ActualEffort', 'RemainingEffort', 'Work');
$request[] = new SoapVar($userQuery, SOAP_ENC_OBJECT, 'EntityQuery', 'http://clarizen.com/api/queries');
//Execute the request
$result = $client->Execute(array("request"=>$request));
//echo "<pre>";print_r($result);echo "</pre>";die();
if($result->ExecuteResult->Result->Success == 1 && $result->ExecuteResult->Result->Error == ''){
$taskArray = array();
foreach($result->ExecuteResult->Result->Entities->BaseEntity as $key => $values){
if(count($values->Values->FieldValue) > 0){
$data = $values->Values->FieldValue;
$temp = array(
'Name' =>$data[0]->Value,
'Project' =>$data[1]->Value->Values->FieldValue->Value,
'Parent' =>$data[2]->Value->Values->FieldValue->Value,
'CreatedOn' => substr($data[10]->Value,0,10),
'LastUpdatedOn' => substr($data[11]->Value,0,10),
'StartDate' => substr($data[3]->Value,0,10),
'DueDate' => substr($data[4]->Value,0,10),
'State' => $data[6]->Value->Id->Value,
'Manager' => $data[7]->Value->Values->FieldValue->Value,
'TrackStatus' => $data[8]->Value->Id->Value,
'Description' => $data[12]->Value,
'ActualEffort' => (3600 * $data[13]->Value->Value),
'RemainingEffort' => (3600 * $data[14]->Value->Value),
'Work' => (3600 * $data[15]->Value->Value)
);
$taskArray[$temp['Project']][]= $temp;
unset($temp);
}
}
echo "<pre>";
print_r($taskArray);
echo "</pre>";
die();
}
=========================================================