ddeboer / DdeboerSalesforceMapperBundle

A Salesforce mapper bundle for Symfony2
28 stars 27 forks source link

Model id saving as array #10

Open fernholz opened 11 years ago

fernholz commented 11 years ago

For some reason my id is an array with 2 elements, both of which are the correct Id for the Salesforce Entry. Any idea what may be causing that.

Also, I wrote a model generator as we we have super customized and unique salesforce data, it builds properly, but I can't seem to get the data out, even though it is in the queryResult as 'any'. Does anyone have some working sample code so I can see the error of my ways?

Thanks for these awesome bundles, btw.

ddeboer commented 11 years ago

You're welcome. Can you post some code samples, so we can see what you're trying to accomplish?

fernholz commented 11 years ago
object(Ddeboer\Salesforce\MapperBundle\Model\JournalAds)[973]
  protected 'accountBoEBioURLPath' => null
  protected 'accountNumber' => null
  protected 'accountSpokenLanguage' => null
  protected 'accountTeaching' => null
  protected 'accountURLSlug' => null
  protected 'accountWillingToTravel' => null
  protected 'adFirstName' => null
  protected 'adFullName' => null
  protected 'adLanguage' => null
  protected 'adLastName' => null
  protected 'adMiddleName' => null
  protected 'adOrgAccountName' => null
  protected 'adOrganizationName' => null
  protected 'adSuffix' => null
  protected 'adTextAfter' => null
  protected 'adTextBefore' => null
  protected 'adTextOnline' => null
  protected 'adTitle' => null
  protected 'adName' => null
  protected 'advertiserStatus' => null
  protected 'advertiserType' => null
  protected 'afterNameSuffix' => null
  protected 'alsoAvailableData' => null
  protected 'associationLocation' => null
  protected 'beforeAdvertiserName' => null
  protected 'beforeAssociationLocation' => null
  protected 'beforeClassLocation' => null
  protected 'beforeMailingStreet' => null
  protected 'beforePrimaryStreet' => null
  protected 'boLBio' => null
  protected 'boLBioDailyLiftURL' => null
  protected 'boLBioPublish' => null
  protected 'boLBioTitle' => null
  protected 'boLBioVideoLink' => null
  protected 'boLBioWebsite' => null
  protected 'boLHiResHeadshot1' => null
  protected 'boLHiResHeadshot2' => null
  protected 'boLLocation' => null
  protected 'boLLocationDisplay' => null
  protected 'boLOnlineLecture1' => null
  protected 'boLOnlineLecture2' => null
  protected 'boLOnlineLecture3' => null
  protected 'boLOnlineLecture4' => null
  protected 'boLSmallHeadshot' => null
  protected 'boLVideoTitleImage' => null
  protected 'bookmarkID' => null
  protected 'branchNameNumber' => null
  protected 'branchNumber' => null
  protected 'branchNumberAudit' => null
  protected 'cardType' => null
  protected 'classAssocinCombined' => null
  protected 'classLocation' => null
  protected 'compiledAdHours' => null
  protected 'cOPCityState' => null
  protected 'country' => null
  protected 'countryISO' => null
  protected 'countryPhoneCode' => null
  protected 'createdById' => null
  protected 'createdDate' => null
  protected 'cSBBio' => null
  protected 'cSBBioAssociationLanguage' => null
  protected 'cSBBioAssociationLocation' => null
  protected 'cSBBioAssociationTime' => null
  protected 'cSBBioClassCountry' => null
  protected 'cSBBioClassLanguage' => null
  protected 'cSBBioClassLocation' => null
  protected 'cSBBioClassTime' => null
  protected 'cSBBioLecturerProfileURL' => null
  protected 'cSBBioNotes' => null
  protected 'cSBBioOtherContact' => null
  protected 'cSBBioPublish' => null
  protected 'cSBBioWebsite2' => null
  protected 'cSOCityState' => null
  protected 'daysandHours' => null
  protected 'email' => null
  protected 'emailText' => null
  protected 'fullName' => null
  protected 'heraldCountry' => null
  protected 'heraldSortCountry' => null
  protected 'heraldSpokenLanguages' => null
  protected 'heraldStateCodeOverride' => null
  protected 'id' => 
    array
      0 => string 'a1170000000Y0aWAAS' (length=18)
      1 => string 'a1170000000Y0aWAAS' (length=18)
  protected 'iMScreenName' => null
  protected 'iMType' => null
  protected 'isActive' => null
  protected 'isLecturer' => null
  protected 'isDeleted' => null
  protected 'isTeaching' => null
  protected 'journalAdStatus' => null
  protected 'journalAdType' => null
  protected 'lastModifiedById' => null
  protected 'lastModifiedDate' => null
  protected 'latitude' => null
  protected 'longitude' => null
  protected 'mailingAddressDistrict' => null
  protected 'mailingAddressText' => null
  protected 'mailingAddressTextOnline' => null
  protected 'mailingCity' => null
  protected 'mailingCountry' => null
  protected 'mailingMetroRegion' => null
  protected 'mailingStateProvince' => null
  protected 'mailingStreet' => null
  protected 'mailingSubCountry' => null
  protected 'mailingWorldRegion' => null
  protected 'mailingZipPostalCode' => null
  protected 'mailingSortCity' => null
  protected 'mailingSortCountry' => null
  protected 'mailingSortDistrict' => null
  protected 'mailingSortState' => null
  protected 'mailingZip' => null
  protected 'metroRegion' => null
  protected 'militaryBranch' => null
  protected 'militaryTitle' => null
  protected 'name' => null
  protected 'oldCardLine' => null
  protected 'onlineZipPostalCode' => null
  protected 'phone' => null
  protected 'phoneText' => null
  protected 'primaryAddressDistrict' => null
  protected 'primaryAddressText' => null
  protected 'primaryAddressTextOnline' => null
  protected 'primaryAddressType' => null
  protected 'primaryCity' => null
  protected 'primaryContact' => null
  protected 'primaryContactEmail' => null
  protected 'primaryContactPhone' => null
  protected 'primaryCountry' => null
  protected 'primaryEmail' => null
  more elements...

This is 1 of the objects I'm getting back, which indicates the $id issue. The model is huge, I could share a gist with you.

Calling like this -

    $result = $this->get('ddeboer_salesforce_mapper')->findBy(new Model\JournalAds(),
            array(
                'cSBBioPublish' => true
            )
        );

        return $result;

for now I'm just foreaching over the result and dumping in a twig template to get the above output.

ddeboer commented 11 years ago

I've seen the partner WSDL returning the ID as a duplicated array, as described in the Salesforce help. Are you using a partner or enterprise WSDL?

fernholz commented 11 years ago

We are using the partner WSDL, as what we use in a separate integration using pure php and the Salesforce Toolkit.

When I switch to Enterprise WSDL, I get an error.

"Element {}item invalid at this location 500 Internal Server Error - SoapFault"

Stack Trace in /Users/clarity/Sites/journaldirectory/vendor/ddeboer/salesforce-client-bundle/Ddeboer/Salesforce/ClientBundle/Client.php at line 503

        }
        try {
            $result = $this->soapClient->$method($params);
        } catch (\SoapFault $soapFault) {
            if (null !== $this->eventDispatcher) {
                $event = new Event\SoapFaultEvent($soapFault);

I can pull the whole stack trace if that would be helpful.

fernholz commented 11 years ago

And looking at the Salesforce Help link you posted, it would seem that the solution would be to never pass the Id to the query as it is implicitly passed. Perhaps modifying the getQuerySelectPart method on the Mapper Class. Or, more accurately, the getSelect method that implodes all the fields.

fernholz commented 11 years ago

Not really related, but when I do a query direct through your Client Bundle, I get records like this

object(Ddeboer\Salesforce\ClientBundle\Response\SObject)[4447]
  public 'Id' => null
  public 'type' => string 'JournalAds__c' (length=13)
  public 'any' => string <huge xml string of all my data>