UpdateRecord

Permet de mettre à jour un Record.
 
PHP
//Rechercher la tâche à mettre à jour

 

$taskRef = new StdClass();

$taskRef->Type = 'TASK';

$taskRef->Id = 3523;

 

$getTaskRequest = new StdClass();

$getTaskRequest->credentials = $credentials;

$getTaskRequest->recordRef = $taskRef;

$response = $service->GetRecord($getTaskRequest);

$record = $response->record;

 

if (!isset ($record)){

    echo "Task not found<br/>";

    return;

}

$task = $record;

 

 

//Comme php utilise des StdClass, les propertyValue doivent être réencodés en string

if (isset($task->Metas)){

   foreach ($task->Metas->Property as $property){

      $property->Value = new SoapVar($property->Value, XSD_STRING, 'string', 'http://www.w3.org/2001/XMLSchema');

   }

}

 

//Comme php utilise des StdClass, les propertyValue doivent être réencodés en string

if (isset($task->Properties)){

   foreach ($task->Properties->Property as $property){

      $property->Value = new SoapVar($property->Value, XSD_STRING, 'string', 'http://www.w3.org/2001/XMLSchema');

   }

}



 

 

if (isset($task->TaskItemList) ){

    //Comme php utilise des StdClass, les taskItem et TaxAmount doivent être réencodés

   if (isset ($task->TaskItemList->TaskItems) && isset ($task->TaskItemList->TaskItems->Record)){

      foreach ($task->TaskItemList->TaskItems->Record as &$item)

         $item = new SoapVar($item, SOAP_ENC_OBJECT, 'TaskItem', "http://task.v1.ws.progression.diffusion.cc");        

    }

 

    if (isset($task->TaskItemList->TaxAmounts) && isset($task->TaskItemList->TaxAmounts->Record)){

        foreach ($task->TaskItemList->TaxAmounts->Record as &$tax)

            $tax = new SoapVar($tax, SOAP_ENC_OBJECT, 'TaxAmount', "http://task.v1.ws.progression.diffusion.cc");

    }

}

 

 

$task->Summary = 'Nouveau sommaire';

$task->Description = 'Nouvelle description';

$updateRequest = new StdClass();

$updateRequest->credentials = $credentials;

$updateRequest->record = new SoapVar($task, SOAP_ENC_OBJECT, 'Task', "http://task.v1.ws.progression.diffusion.cc");

 

 

try {

    $reponse = $service->UpdateRecord($updateRequest);

} catch (Exception $e){

 

}