You need to sign in to do that
Don't have an account?
Thrantor
Can't access custom contact field in Opportunity using the API.
I've created a Opportunity Contact field for Opportunity which is a lookup on the Contact table.
From salesforce I can see the contact and work with it and everything looks happy.
But when trying to access the contacts information using PHP I get nothing. I'm using the following code:
$queryOpportunity = "Select AccountId, Amount, Paid__c, Opportunity_Contact__c from Opportunity WHERE Id = '$id'" ; $OppResponse = $mySforceConnection->query(($queryOpportunity)); foreach ($OppResponse->records as $OppRecord) { $subtotal = $OppRecord->Amount ; $email = $OppRecord->Opportunity_Contact__c->Email ; var_dump($OppRecord) ; var_dump($OppRecord->Opportunity_Contact__c) ;
And I can't get any of the information for the contact. Help.
Also, Instead of grabbing the AccountID and doing a seperate query on account is there anyway to just grab the account information with this query as well?
I've had problems retrieving certain custom fields when using the wrong version of the SOAP API. I think it's up to 18.0 now. Look through the files in the Toolkit, if I remember correctly, I think you just need to change it in the WSDL XML file, in your case probably the partner WSDL file to https://www.salesforce.com/services/Soap/u/18.0
You can do the kind of query you're talking about - here's an example of one of these nested queries:
Select a.Name, (Select FirstName, LastName From Contacts), (Select Subject From Events), (Select Amount, Name, TotalOpportunityQuantity, Type From Opportunities) from Account a
You should check out the Apex Explorer, it makes testing queries easier. You would also need to change the SOAP version in Apex Explorer, under Tools > Options.
best,
-paul
All Answers
I've had problems retrieving certain custom fields when using the wrong version of the SOAP API. I think it's up to 18.0 now. Look through the files in the Toolkit, if I remember correctly, I think you just need to change it in the WSDL XML file, in your case probably the partner WSDL file to https://www.salesforce.com/services/Soap/u/18.0
You can do the kind of query you're talking about - here's an example of one of these nested queries:
Select a.Name, (Select FirstName, LastName From Contacts), (Select Subject From Events), (Select Amount, Name, TotalOpportunityQuantity, Type From Opportunities) from Account a
You should check out the Apex Explorer, it makes testing queries easier. You would also need to change the SOAP version in Apex Explorer, under Tools > Options.
best,
-paul
Thank you. You're response helped GREATLY. I ended up going with this as a query:
Although, I did have to add another line to the line I already had in the enterprise.xml:
After that... I'm getting valid data back. WOOT!
New to the API, having the same problem... just so I understand, I am using the partner wsdl, and have no problem connecting. Created a custom 'Kcontact' object that contains a number of fields, name__C, email__c, just for testing purposes.
Running the following query, I only get a response from the Id field, none of the custom fields...
And here is the response:
So I will need to manually add name__c, email__c, etc to the partner wsdl XML file? I added these via the website and re-downloaded the partner wsdl file from SF, but still getting nothing back for my custom columns.
I am using 13.1 of the PHP toolkit, fyi.
Thanks for any clarification!