+ Reply to Thread
Results 1 to 2 of 2
This is a discussion on Issue while inserting new task into salesfore using PHP within the Salesforce Coding Discussions forums, part of the Salesforce category; Hi, Im facing problem when i try to insert/update the ActivityDate field
  1. #1
    blessang is offline Junior Member
    Join Date
    Dec 2008
    Posts
    1

    Issue while inserting new task into salesfore using PHP

    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.
    Last edited by mike; 12-03-2008 at 06:12 AM. Reason: edited by mike - remove email from login info

  2. #2
    mike's Avatar
    mike is offline Administrator
    Join Date
    May 2007
    Location
    Wylie, Texas
    Posts
    607
    Blog Entries
    16
    What error(s) are you getting sir?

    ~Mike

+ Reply to Thread

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

SEO by vBSEO 3.5.2