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
n10ctn10ct 

Adding Custom Fields and Upserts

We're closing in on integration with PE, but there still remains a couple of questions and a naming issue.
  1. How do we automatically add a custom field to accounts which use our program?
  2. Why must upsert connect with a custom field, vs. using the standard Email field as the external ID?

The issue we’re facing now is that the field names do not always work with upsert. For example, in contacts, there is a required field named “Name” which, when an upsert is attempted, returns the error “No such column 'Name' on entity 'contact'”. Is there an exhaustive list of true field names which work with upsert for every type (lead, contact, account)?

SuperfellSuperfell
There is no Name field on contact, its firstName & lastName. Use sforce explorer or one of the other tools to examine the schema.
benfaustbenfaust
What is the sforce explorer and where can it and the other tools be found?
n10ctn10ct
Perhaps it is the same as the AppExchange Explorer on this page: http://www.salesforce.com/developer/projects_toolkits.jsp
Tran ManTran Man
That's correct.  Sforce Explorer is called AppExchange Explorer now.  If you use Eclipse, I would recommend the AppExchange Eclipse Plugin.
benfaustbenfaust

Thanks for letting me know the name change. The explorer did the trick.

Leads works properly with upsert as does Contacts. Accounts returns the following error:

Fatal error: Uncaught SoapFault exception: [soapenv:Client] '' is not valid for the type xsd:double in /home/landing/htdocs/new/sforce-php/soapclient/SforceBaseClient.php:526 Stack trace: #0 [internal function]: SoapClient->__call('upsert', Array) #1 /home/landing/htdocs/new/sforce-php/soapclient/SforceBaseClient.php(526): SoapClient->upsert(Object(stdClass)) #2 /home/landing/htdocs/new/salesforce/salesforce.php(130): SforceBaseClient->upsert('emailid__c', Array) #3 /home/landing/htdocs/new/index.php(118): salesforce(Array, Array) #4 {main} thrown in /home/landing/htdocs/new/sforce-php/soapclient/SforceBaseClient.php on line 526

All the code is the same as the other two, the fields are simply a different mapping as follows:

    $FIELDS["account"]=array(
     'Name'=>$data["fname"].' '.$data["lname"],
        'AnnualRevenue'=>$data["annualrevenue"],
     'Phone'=>$data["phone"],
        'Fax'=>$data["fax"],
     'Email'=>$data["email"],
     'BillingStreet'=>$data["addr1"].' / '.$data["addr2"],
     'BillingCity'=>$data["city"],
     'BillingState'=>$data["state"],
     'BillingPostalCode'=>$data["zip"],
     'BillingCountry'=>$data["country"],
        'Extra_Information__c'=>'',
        'emailid__c'=>$data["email"]
 );

I have no idea to what the error is referring. Any insights?

SuperfellSuperfell
You're probably passing an empty string for the annualrevenue field, but as per the XML schema spec, empty string is not a valid value for the double data type.