Hi,
Im facing problem when i try to insert/update the ActivityDate field in Task table. Im able to upsert task if not passing the ActivityDate( Duedate).
Please find the code below
PHP Code:
$wsdl = './soapclient/partner.wsdl.xml';
$userName = "email@password.com";
$password = "password";
$client = new SforcePartnerClient();
$client->createConnection($wsdl);
$loginResult = $client->login($userName, $password);
$tasks = get_tasks($client);
if ($tasks)
{
...
...
$sObjects = array();
foreach ($accounts as $fieldset)
{
$sObject = new sObject();
$sObject->type = 'Task'; // Salesforce Table or object that you will perform the upsert on
$sObject->fields = $fieldset;
array_push($sObjects, $sObject);
}
$success = upsert_accounts($client, $sObjects, $file_updated, $file_created, $file_failed);
// Update the overall counts
if (is_array($success))
{
$accounts_created = $accounts_created + $success[0];
$accounts_updated = $accounts_updated + $success[1];
$accounts_failed = $accounts_failed + $success[2];
}
$starting_record = $starting_record + $number_records;
ob_start();
$total_record_count = $total_record_count + $record_count;
echo $total_record_count." records processed.<br />";
ob_end_flush();
}
function upsert_accounts($client, $sObjects, $file_updated, $file_created, $file_failed)
{
$accounts_created = 0;
$accounts_updated = 0;
$accounts_failed = 0;
try
{
// The upsert process
print_r($sObjects);
$results = $client->upsert("ACTIVITY_ID__C", $sObjects); //ACTIVITY_ID__C is the external id
echo "here";
print_r($results);
}
function get_tasks($connection)
{
echo "<br>AS";
$accounts = array();
$query = "select * from sforce_task"; //local mysql table
$res = mysql_query($query);
$i=0;
while ($row = mysql_fetch_array($res)) {
//array_push($accounts, $row);
/*
$accounts[$i]['EXT_ID__C'] = htmlspecialchars(stripslashes(strip_tags($row['ext_id__c'])));
$accounts[$i]['SLASerialNumber__c'] = htmlspecialchars($row['SLASerialNumber__c']);
$accounts[$i]['SITE'] = htmlspecialchars($row['Site']);
*/
$accounts[$i]['ACTIVITY_ID__C'] = htmlspecialchars(stripslashes(strip_tags($row['Activity_Id__c'])));
$accounts[$i]['ACTIVITYDATE'] = ($row['ActivityDate']); //if this line is commented, the code works fine.
$accounts[$i]['SUBJECT'] = htmlspecialchars($row['Subject']);
$accounts[$i]['WHATID'] = htmlspecialchars($row['WhatId']);
// You can add addtional rows here if needed
$i++;
}
return $accounts;
}
Thanks in advance. Please help.
Bookmarks