function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Ted.TsungTed.Tsung 

php whatId info

Is there a php call that can obtain the 'Name' value of the WhatId field in the Task object?
msimondsmsimonds
You mean something like this?  Code:
<—php
ini_set("soap.wsdl_cache_enabled", "0");


require_once ('./includes/soapclient/SforcePartnerClient.php');
require_once ('./includes/soapclient/SforceHeaderOptions.php');

$wsdl = './includes/soapclient/partner.wsdl.xml';
$userName = "email@password.com";
$password = "password";

$client = new SforcePartnerClient();
$client->createConnection($wsdl);
$loginResult = $client->login($userName, $password);

try
{
    $query = "Select WhatId FROM Task";


    $queryOptions = new QueryOptions(500);
    $response = $client->query(($query), $queryOptions);
    // check count to see if we are done
    if ($response->size > 0)
    {
        $accounts = $response->records;
        // Cycles through additional responses if the number of records
        // exceeds the batch size
        while (!$response->done)
        {
            set_time_limit(100);
            $response = $client->queryMore($response->queryLocator);
            $accounts = array_merge($accounts, $response->records);

        }
    }
    echo '<pre>' . print_r($accounts, true) . '</pre>';
    exit;
}
catch (exception $e)
{
    // This is reached if there is a major problem in the data or with
    // the salesforce.com connection. Normal data errors are caught by
    // salesforce.com
    echo '<pre>' . print_r($e, true) . '</pre>';
    return false;
}
–>

 

Ted.TsungTed.Tsung

Not exactly. I know how to do that. The question is about how to determine the target object of the WhatId. In your example, you will get all the WhatId from the task object but how do you construct query to get the "Name" value for each returned WhatId?

Thanks,

Ted Tsung

msimondsmsimonds
So the WhatId is the account that the task is associated or the opportunity>  Sorry to ask this, but I haven't worked with this object before


~Mike
Ted.TsungTed.Tsung

WhatId can be associated with almost all the standard and custom objects. In my case, we have a dozen custom objects that can link to the WhatId. So we are looking for a quick way to determine what object is associated with the WhatId.

Ted

Alex 2.0Alex 2.0
Here's a quick way:

http://www.salesforce.com/us/developer/tech-notes.jsp?tn=TN-1

--Alex

Ted.TsungTed.Tsung
Thanks for the tip