You need to sign in to do that
Don't have an account?
jsh
PHP - Create Task
I'm having trouble with what seems to be a simple function to create a
Task with PHP. Below is the code I'm using. I have hard
coded ID's in where appropriate for testing...
$createFields = array (
'AccountID' => '0013000000Dd0ZV',
'ActivityDate' => gmdate("Y-m-d H:i:s", time()),
'Description' => 'My Description',
'IsClosed' => '0',
'OwnerId' => '00530000000t3av',
'Priority' =>'High',
'Status' => 'In Progress',
'Subject' => 'Call',
'WhatID' =>'0013000000Dd0ZV',
'WhoID' =>'0033000000F6Bb1'
);
$sObject1 = new SObject();
$sObject1->fields = $createFields;
$sObject1->type = 'Task';
$createResponse = $mySforceConnection->create(array($sObject1));
I have a valid $mySforceConnection.
I get a silent failure. I can create a Contact fine. Also, I have checked the describeSObject on the Task object and it is Createable.
:smileysad:
$createFields = array (
'AccountID' => '0013000000Dd0ZV',
'ActivityDate' => gmdate("Y-m-d H:i:s", time()),
'Description' => 'My Description',
'IsClosed' => '0',
'OwnerId' => '00530000000t3av',
'Priority' =>'High',
'Status' => 'In Progress',
'Subject' => 'Call',
'WhatID' =>'0013000000Dd0ZV',
'WhoID' =>'0033000000F6Bb1'
);
$sObject1 = new SObject();
$sObject1->fields = $createFields;
$sObject1->type = 'Task';
$createResponse = $mySforceConnection->create(array($sObject1));
I have a valid $mySforceConnection.
I get a silent failure. I can create a Contact fine. Also, I have checked the describeSObject on the Task object and it is Createable.
:smileysad:
echo "<BR><BR>CREATE RESPONSE: ".$createReponse."<BR><BR>";
and I get a empty response.
I am using a try catch, and the catch clause does not run either.
I think I need to get the correct Status and Priority IDs from those tables rather than setting them as strings?
AccountID and IsClosed can not be programmatically set. THey are set by the api based on the WhoID and Status fields.
THe following code works:
$createFields = array (
'ActivityDate' => gmdate("Y-m-d H:i:s", time()),
'Description' => 'SUCCESSFULLY CREATE A NEW TASK IN PHP: ',
'OwnerId' => $_SESSION['sf_userID'],
'Priority' =>'Normal',
'Status' => 'Completed',
'Subject' => 'ProgrammaticTask',
'WhatID' =>'0013000000Dd0ZV',
'WhoID' =>'0033000000F6Bb1'
);
$sObject1 = new SObject();
$sObject1->fields = $createFields;
$sObject1->type = 'Task';
$createResponse = $mySforceConnection->create(array($sObject1));
Thanks for the help!
I've tried your code, but I have the following problem with the activitydate field (code working without this field, not working with this field..).
create one: Array ( [errors] => Array ( [fields] => [message] => �ch�ance uniquement: valeur de type non valide�: 2006-10-11 10:28:05 [statusCode] => INVALID_TYPE_ON_FIELD_IN_RECORD ) [id] => [success] => false )
Do you have any idea on when it can come from ?
Best regards,
TB.
Complete code :
// Creer La Tache
$task = new sObject('Task',
null,
array(
'Status' => 'Completed',
'Subject' => 'Appeler',
'WhatId' => $idsur18car,
'Type' => 'A Rappeler',
'ActivityDate' => gmdate("Y-m-d H:i:s", time()),
)
);
$createResult = $sfdc->create($task);