+ Reply to Thread
Results 1 to 2 of 2

Thread: List all leads

  1. #1
    ncee is offline Junior Member
    Join Date
    Oct 2007
    Posts
    14

    List all leads

    Hey Mike,

    I'm trying to view all the spam in our salesforce account. Here's what I got:

    PHP Code:
        include "loginInfo.php";
        require_once (
    './includes/soapclient/SforcePartnerClient.php');
        require_once (
    './includes/soapclient/SforceHeaderOptions.php');
        require_once (
    './includes/soapclient/SforceBaseClient.php');
        
        
    $mySforceConnection = new SforcePartnerClient();
        
    $mySoapClient $mySforceConnection->createConnection("partner.wsdl.xml");
        
    $mylogin $mySforceConnection->login($username$password);

        
    $query "Select LastName, Id, Email, FirstName From Lead WHERE
                    Email LIKE '%tivan%' OR
                    Email LIKE '%ialis%' OR
                    Email LIKE '%evitra%' OR
                    Email LIKE '%ropecia%' OR
                    Email LIKE '%ramadol%' OR
                    Email LIKE '%alium%' OR
                    Email LIKE '%iagra%' OR
                    Email LIKE '%anax%'
                    Order by Email"
    ;    
                    
        
    $queryResult $mySforceConnection->query($query);
        
    $records $queryResult->records;    
        
        if(
    sizeof($records) > 0)
        {
            echo 
    "<center><table border=1>\n<tr><th>ID</th><th>Email</th><th>Firstname</th><th>Lastname</th></tr>\n";
            foreach (
    $records as $record
            {
                
                
    $sObject = new SObject($record);
                
    $id $sObject->Id;
                
    $first $sObject->fields->FirstName;
                
    $last $sObject->fields->LastName;
                
    $email $sObject->fields->Email;

                if(
    strlen($first) == 0)
                    
    $first "[not provided]";
                    
                if(
    strlen($last) == 0)
                    
    $last "[not provided]";
                    
                echo 
    "<tr><td>$id</td><td>$email</td><td>$first</td><td>$last</td></tr>\n";
            }
            echo 
    "</table></center>";
        } 
    For some reason, I'm only pulling the Id and not the FirstName, LastName and Email. Any ideas on what I'm doing wrong?
    Last edited by ncee; 01-26-2009 at 09:57 AM. Reason: transposed code

  2. #2
    mike's Avatar
    mike is offline Administrator
    Join Date
    May 2007
    Location
    Wylie, Texas
    Posts
    557
    Blog Entries
    15
    do a
    PHP Code:
    echo '<pre>' print_r($records,true) . '</pre>'
    and paste it here so I can take a look at it

    That will help see what is going on

    ~Mike


    OR

    echo out your SOQL statement and put it into the data loader or eclipse and see if you get any results. Seems like it is a SOQL problem man
    Last edited by mike; 01-26-2009 at 11:09 AM. Reason: adding stuff

+ Reply to 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.1