+ Reply to Thread
Results 1 to 8 of 8
This is a discussion on PHP loop on sObjects and eval() within the Salesforce PHP Tutorials forums, part of the Salesforce category; I have been trying to get through the loop on sObjects with
  1. #1
    lashak is offline Junior Member
    Join Date
    Jan 2010
    Posts
    5

    PHP loop on sObjects and eval()

    I have been trying to get through the loop on sObjects with no luck. I have gone through the PHP eval() that Mike put together on this site, but all I ever got back was 65 fields of the main ID, not all of the sObjects and thier fields. When I do what I am doing below, I get the error
    "Object of class SObject could not be converted to string" and I am just stumped on what field is incorrect. I would love to be able to use the eval on the below code and dump that to the returning array.


    Any help or guidance will be greatly appreciated. Thank you,




    function getSalesforceIDInfoMonster($salesforce_id)
    {
    global $mySforceConnection;

    $query = "Select o.W_L_D_Comments__c, o.Type, o.TotalOpportunityQuantity, o.Telemarketing_Manager__r.Manager__c,
    o.Telemarketing_Manager__c, o.Telemarketing_Agent__r.Name, o.Telemarketing_Agent__r.Id,
    o.Telemarketing_Agent__c, o.SystemModstamp, o.Suite__c, o.Sub_Type__c, o.StageName,
    o.Sourceofurgency__c, o.Short_Description__c, o.Sales_Representative__c, o.Regional_Sales_Mgr__c,
    o.RecordTypeId, o.Reason_Lost__c, o.Probability, o.Primary_Competitor__c, o.Pricebook2Id,
    o.Planned_Start_Date__c, o.Planned_Finish_Date__c, o.PSA_Opp_ID__c,
    o.Owner.Manager_Emp__c, o.Owner.Manager__c, o.Owner.ForecastEnabled, o.Owner.UserPermissionsAvantgoUser,
    o.Owner.UserPermissionsWirelessUser, o.Owner.UserPermissionsOfflineUser, o.Owner.UserPermissionsMarketingUser,
    o.Owner.OfflineTrialExpirationDate, o.Owner.SystemModstamp, o.Owner.LastModifiedById, o.Owner.LastModifiedDate,
    o.Owner.CreatedById, o.Owner.CreatedDate, o.Owner.LastLoginDate, o.Owner.WirelessEmail, o.Owner.EmployeeNumber,
    o.Owner.LanguageLocaleKey, o.Owner.ProfileId, o.Owner.CurrencyIsoCode, o.Owner.DefaultCurrencyIsoCode,
    o.Owner.EmailEncodingKey, o.Owner.ReceivesInfoEmails, o.Owner.LocaleSidKey, o.Owner.UserRoleId,
    o.Owner.TimeZoneSidKey, o.Owner.IsActive, o.Owner.Alias, o.Owner.MobilePhone, o.Owner.Fax, o.Owner.Phone,
    o.Owner.Email, o.Owner.Country, o.Owner.PostalCode, o.Owner.State, o.Owner.City, o.Owner.Street,
    o.Owner.Title, o.Owner.Department, o.Owner.Division, o.Owner.CompanyName, o.Owner.FirstName, o.Owner.LastName,
    o.Owner.Username, o.Owner.Id, o.OwnerId, o.Opportunity_ID__c, o.Number_of_SHCM_Products__c,
    o.Number_of_S3_Products__c, o.Number_of_M3_Products__c, o.Name, o.Marketing_Import_Information__c,
    o.Maintenance_Amount__c, o.Lost_To__c, o.Lost_To_Other__c, o.Lead_Source_Code__c, o.LeadSource,
    o.LastModifiedDate, o.LastModifiedById, o.LastActivityDate, o.IsWon, o.IsClosed, o.Inside_Sales__c,
    o.Inside_Sales_Rep__c, o.Id, o.Forecast__c, o.ForecastCategoryName, o.ForecastCategory, o.FiscalYear,
    o.FiscalQuarter, o.Fiscal, o.Executive_Forecast__c, o.Entry_Date__c, o.Discount__c, o.Description,
    o.Deferred_on_Date__c, o.Customer_Type__c, o.Current_Client_Product__c, o.CurrencyIsoCode, o.CreatedDate,
    o.CreatedById, o.Contract_Status__c, o.Contract_Received__c, o.Complete_RADAR_encrypted__c,
    o.Competition_Description__c, o.CloseDate, o.CampaignId, o.Associated_GPS__c, o.Amount,
    o.Account.Lawson_Industry__c, o.Account.Support_Level__c, o.Account.Business_Unit__c,
    o.Account.Business_Unit_Override__c, o.Account.Official_Name__c,
    o.Account.Workgroup__c, o.Account.D_U_N_S__c, o.Account.Marketing_Import_Information__c,
    o.Account.Import_Tag__c, o.Account.X3rd_SIC_Industry__c, o.Account.X3rd_SIC_Segment__c,
    o.Account.X2nd_SIC_Segment__c, o.Account.X2nd_SIC_Industry__c, o.Account.Do_Not_Contact__c,
    o.Account.Population__c, o.Account.of_Facilities__c, o.Account.Outpatient_Visits_Year__c,
    o.Account.of_Beds__c, o.Account.Inpatient_Visits_Year__c, o.Account.Client_Fiscal_Year_End__c,
    o.Account.Primary_SIC_Segment__c, o.Account.Client_Since__c, o.Account.Primary_SIC_Industry__c,
    o.Account.CTPS__c, o.Account.Vertical__c, o.Account.Global_Location__c, o.Account.Phone_Ext__c,
    o.Account.Micro_Segment__c, o.Account.Status__c, o.Account.SIC_Code2__c, o.Account.SIC_code__c,
    o.Account.Client_ID__c, o.Account.Country_Code__c, o.Account.X3rd_SIC_Code__c, o.Account.IsPartner,
    o.Account.SystemModstamp, o.Account.LastModifiedById, o.Account.LastModifiedDate, o.Account.CreatedById,
    o.Account.CreatedDate, o.Account.OwnerId, o.Account.CurrencyIsoCode, o.Account.TickerSymbol,
    o.Account.Ownership, o.Account.NumberOfEmployees, o.Account.AnnualRevenue, o.Account.Industry,
    o.Account.Website, o.Account.Fax, o.Account.Phone, o.Account.ShippingCountry, o.Account.ShippingPostalCode,
    o.Account.ShippingState, o.Account.ShippingCity, o.Account.ShippingStreet, o.Account.BillingCountry,
    o.Account.BillingPostalCode, o.Account.BillingState, o.Account.BillingCity, o.Account.BillingStreet,
    o.Account.ParentId, o.Account.Name, o.Account.Id, o.AccountId From Opportunity o
    Where o.Id = '
    $salesforce_id'";

    try
    {

    $response = $mySforceConnection->query(($query));

    $queryResult = new QueryResult($response);

    /* Error occurred, return given name by default */
    if(!$queryResult|| $queryResult->size < 1)
    {
    return NULL;
    }



    foreach ($queryResult->records as $record)
    {
    $dbarray[]=$record;
    }

    }
    catch (Exception $e)
    {
    print_r($mySforceConnection->getLastRequest());
    echo $e->faultstring;
    }
    return $dbarray;
    } //end func

    <
    html>
    <
    head>
    <linkrel="stylesheet"type="text/css"media="screen"href="styles.css"/>
    </head>
    <body>

    <?php



    //test getSalesforceIDInfoMonster($salesforce_id)


    echo


    "<h1>getSalesforceIDInfoMonster($salesforce_id)</h1>";


    $salesforceInfo = getSalesforceIDInfoMonster("0063000000Gd0MIAAZ");

    //$salesforceInfo = getSalesforceIDInfoMonster("006S0000002eGNaIAM");

    echo "<table>";

    foreach ($salesforceInfo as $key => $value)
    {
    echo "<tr><td>$key</td><td>$value</td></tr>";
    }

    echo "</table>";

    echo "<h1>END getSalesforceIDInfoMonster($salesforce_id) test</h1>";


    echo "<hr>";

    ?>

    </body>
    </html>
    Last edited by lashak; 01-07-2010 at 10:33 AM.

  2. #2
    mike's Avatar
    mike is offline Administrator
    Join Date
    May 2007
    Location
    Wylie, Texas
    Posts
    607
    Blog Entries
    16

    sorry it took so long to respond

    Did you try and do a print_r on the data ? Are you up to using alternate code that may work better? Tomorrow I can post some example code that I use to get records out of Salesforce. It is a function called get_records.

    I think it is somewhere on this site, but honestly I cannot remember!!

    ~Mike

  3. #3
    lashak is offline Junior Member
    Join Date
    Jan 2010
    Posts
    5
    Thanks Mike, I have tried a get_records method that was part of the eval snippit you have put out here, except it only ever showed me the first ID fields of the passThis2('ID') = r.id as my query result is treated as one record. I really need to be able to get to all of the sObjects part of this record.

  4. #4
    mike's Avatar
    mike is offline Administrator
    Join Date
    May 2007
    Location
    Wylie, Texas
    Posts
    607
    Blog Entries
    16
    Lashak can you do me a favor and email me the script to masimonds at gmail . com ????

  5. #5
    lashak is offline Junior Member
    Join Date
    Jan 2010
    Posts
    5
    on its way to you. I sent the above script I have as well as your php eval that used the get_records.

  6. #6
    mike's Avatar
    mike is offline Administrator
    Join Date
    May 2007
    Location
    Wylie, Texas
    Posts
    607
    Blog Entries
    16
    Yeah I received it, let me look at it. I sent you a reply. I am getting ready to go eat lunch, but will be back in about an hour or so

  7. #7
    mike's Avatar
    mike is offline Administrator
    Join Date
    May 2007
    Location
    Wylie, Texas
    Posts
    607
    Blog Entries
    16
    okay i am working on this

    I will attach a script here in awhile and we shall see if this works!!

    ~Mike

  8. #8
    mike's Avatar
    mike is offline Administrator
    Join Date
    May 2007
    Location
    Wylie, Texas
    Posts
    607
    Blog Entries
    16
    I sent you an email with two scripts in it!!

    I tested them and they work, let me know if you have any other issues


    ~Mike

+ 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.2