You need to sign in to do that
Don't have an account?
benv
Custom Formula field in SOQL query, describeSObject, PHP
I can't query a custom formula field in the product2 object. I don't get an error when I put it in the SOQL SELECT statement, but I can't select it. I can select it from the Excel Connector, so it must be possible.
Code:
$query_all_products = "select Id, ProductCode, Quantity__c, Warehouse_Location__c, WeightOunces__c, Shipping_Weight_Formula__c from product2"; $result = $sforce->query(array("queryString" => $query_all_products)); $all_products=$result->result->records; echo '<pre>'.print_r($all_products,true).'</pre>';
Warehouse_Location__cdoesn't show up in the resulting object.And when I try using describeSObject:
$contact= $sforce->describeSObject("Contact"); print_r($contact);I get this error: Fatal error: Uncaught SoapFault exception: [sf:INVALID_TYPE] INVALID_TYPE: sObject type cannot be null in (filename):3 Stack trace: #0 [internal function]: SoapClient->__call('describeSObject', Array) #1 (filename)(3): SoapClient->describeSObject('Contact') #2 {main} thrown in (filename) on line 3 Any ideas?
I think you just need some small adjustments in your code:
try this code (make sure you change the query):
Code:
and your describeObject is going against the Contact object.
So you will never see your custom field:
Maybe try this utlitity script that I posted on my site
And on my describeSObject example, I used Contact just to show that it has nothing to do with a custom object or custom fields, I simply can't get describeSObject to work no matter what.
When I tried using your describeGlobal example, it just said that $result->types was an invalid argument for foreach.
Maybe something wrong w/ my wsdl or connection script? Even though I've had a lot of query/update/delete scripts working for months...
Here's the connection script.
Code:
So msimonds, I very much appreciate the response, but I'm still right where I started.
1) In your first post, you never stated that they were two separate problems, they looked like they were tied together.
2) Something must be wrong with your setup because the describeGlobal example that I showed you works fine on 3 different servers that I use for development
a) did you change your php version lately
b) maybe something is wrong with your wsdl (as you stated), try getting a new partner wsdl file > especially since you stated that you have run lots of queries.
Anyway best of luck, I hope that you get your problems corrected
~Mike
I added a checkbox field called Always_Ship_UPS__c to the product2 object. I downloaded a new enterprise WSDL (since I currently only develop for one organization). I finally got a describeSObject() call to work:
Code: (previously I was just trying $sforce->describeSObject("product2") which didn't work.)
The new field Always_Ship_UPS__c shows up in the describeSObject() result. I also successfully updated the field using $sforce->update().
But when I put it in the field list of a SELECT statement, I don't get an error, but it never shows up in my result, whether or not the field has a value in Salesforce. This is the same thing that happened previously when I tried querying a custom formula field.
Any ideas?
Message Edited by benv on 10-15-2007 04:21 PM
The new field Always_Ship_UPS__c shows up in the describeSObject() result. I also successfully updated the field using $sforce->update().
But when I put it in the field list of a SELECT statement, I don't get an error, but it never shows up in my result, whether or not the field has a value in Salesforce. This is the same thing that happened previously when I tried querying a custom formula field.
Any ideas?
Message Edited by benv on 10-15-2007 04:21 PM
I have this problem exactly several feilds just can not be selected. I ahve the most current WSDL they appear as objects with a describeSObject() but no columns are returning. Hell I even did a SELECT Id,fieldname from Account where Id='basdfasd' and it returned this
Salesforce not displaying Custom Fields when perform SELECT statement QUERY for the API
(excuse all the key words, just helping people find it)
After a day of searching and finding various answers, this is the solution I found to solve the issue with not being able to actually see the values of custom fields in SELECT statements for Saleforce Queries.
Step 1: Make sure you have updated your WSDL XML file after you create any new custom fields
From within Salesforce:
> Setup > Develop > API
Generate Enterprise WSDL (or Partner WSDL) which ever applies to your personal needs
Save the newly created WSDL XML file over top of your existing WSDL file (generally found under /SOAPCLIENT/
If this solves your problem. GREAT! If not, try the next step.
Step 2: Make sure your WSDL file is not being cached, by using the following PHP code:
I also included this prior to creating my Salesforce Connection, to prevent WSDL caching.