2

Using the Salesforce SOAP API to query some data from accountContactRole table. What is the best way to get a relationship value from the query result. When I perform the query in workbench or developer query editor it returns the correct data but I need to know how from my SOAP API VB.NET code would I get the Contact.Contact_Number__c value from the queryResult object?

 soql = String.Format("SELECT AccountId, ContactId, Contact.Contact_Number__c FROM AccountContactRole where accountid = '{0}' and role = '{1}' limit 1", salesforceAccountId, roleName)

        qr = binding.query(soql)
        If qr.records.Length = 1 Then
            Return qr.records(0) <<<<<<<----------- How to pull out contact.contact_number__c
        End If
  • It should be as simple as qr.records(0).Contact.Contact_Number__c, isn't it? – sfdcfox Oct 26 '16 at 20:07
  • @sfdcfox that is what I initially tried but didn't work, once I cast the value to the AccountContactRole I was able to get at the properties from my answer I posted below. – maguy Oct 26 '16 at 20:10
2

Figured out how to do this by casting the queryResult to an AccountContactRole and voila!

(DirectCast(qr.records(0), EnterpriseSF.AccountContactRole)).Contact.Contact_Number__c

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.