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
Dave Frankenbach @ EADave Frankenbach @ EA 

Workbench SOQL related object errors

According to the help file

 

SELECT Account.Name, LastName, FirstName, Owner.Name FROM Contact

 

is supposed to work. All I get are error messages:

 

Parent relationship queries are not allowed: Account.Name

SabrentSabrent

Account is a Parent of Contact

 

As per documentation  -

 

 

For child-to-parent relationships, the relationship name to the parent is the name of the foreign key, and there is arelationshipNameproperty that holds the reference to the parent object. For example, the Contact child object has a child-to-parent relationship to the Account object, so the value ofrelationshipNamein Contact isAccount. These relationships are traversed by specifying the parent using dot notation in the query, for example:

 

SELECT Contact.FirstName, Contact.Account.Name from Contact
SuperfellSuperfell

Is there some kind of API version selector, sounds like its trying to run the query on an old API version

Dave Frankenbach @ EADave Frankenbach @ EA

rov - Your query throws the same error for me. As do all of these

 

SELECT FirstName, Contact.Accountid__r.Name from Contact

SELECT FirstName, Accountid__r.Name from Contact

SELECT FirstName, AccountId.Name from Contact

 

If yours worked for you what can the difference between our environments be?

Dave Frankenbach @ EADave Frankenbach @ EA

Simon - at the top of the workbench it displays API 22.0. If I use the settings page and change the default to 23.0 the SOQL page still displays 22.0 and the dot notation queries still fail. Do I need to try and connect to one of our sandboxes that are flipped to Winter 11 already?

SuperfellSuperfell

relationship queries are available from API v8 onwards, so 22 vs 23 should make no difference.

SabrentSabrent

Try this --

 

Select c.LastName, c.FirstName, (Select Name From Accounts__r) From Contact c

 

Seems like there's no child relationship between owner and contact

Dave Frankenbach @ EADave Frankenbach @ EA

rov - we have PersonAccounts configured so there are relationships between the user, account and contact objects. Contact shows it has Child Relationships to Account.PersonContactId and User.ContactId

 

Here's a list of variations I've tried and the results:

 

Select c.LastName, c.FirstName, (Select Name From Accounts__r) From Contact c
-- Parent relationship queries are not allowed: c.LastName

 

Select c.LastName, c.FirstName From Contact c
-- Parent relationship queries are not allowed: c.LastName
-- the workbench doesn't seem to undestand object aliasing

 

Select c.LastName, c.FirstName From Contact as c
-- Parent relationship queries are not allowed: c.LastName
-- the workbench doesn't seem to undestand object aliasing

 

Select LastName, FirstName, (Select Name From Accounts__r) From Contact
-- invalid type, doesn't understand Accounts__r

 

Select LastName, FirstName, (Select Name From AccountId__r) From Contact
-- invalid type, doesn't understand AccountId__r

 

Select LastName, FirstName, (Select Name From AccountId) From Contact
-- invalid type, doesn't understand AccountId

 

Select LastName, FirstName, (Select Name From Accounts) From Contact
-- invalid type, doesn't understand Accounts

 

Select LastName, FirstName, (Select Name From account where accountid = contact.AccountId) From Contact
-- can't use parent

 

Select LastName, FirstName, (Select Name From account where id = AccountId) From Contact
-- malformed

 

Select LastName, FirstName, (Select Name From account) From Contact
-- invalid type, doesn't understand account

 

switched over and tried to come from the account direction instead of contact


select name, contact.name from account
-- parent relationship not allowed

 

select name, contactid.name from account

-- parent relationship not allowed

 

select name, contactid__r.name from account

-- parent relationship not allowed

 

select name, (select name from contact) from account
-- invalid type, doesn't understand the relationship

 

select name, (select name from contactid) from account
-- invalid type, doesn't understand the relationship

 

select name, (select name from contactid__r) from account
-- invalid type, doesn't understand relationship

 

select name, (select name from contacts) from account
-- works but gives the text "array" as the name output for the contact, not a list of the actual name values

 

It just doesn't seem like the workbench is capable of doing relational object queries.

SuperfellSuperfell

Are you using a local copy of workbench, or the one at workbench.developerforce.com? i was able to run this query fine with the developerforce one

 

select name, (select name from contacts) from account

Dave Frankenbach @ EADave Frankenbach @ EA

Simon - I'm using the web version workbench.developerforce.com

 

That query "works" for me too, as in it doesn't throw an error, but it doesn't give useful data for the contact.name. The output I get is:

 

 NameContact
1John SmithArray
2Jane SmithArray
3Bob RobertsonArray
Rahul SharmaRahul Sharma

Person Account itself is an Account as well as Contact itself.and whenever you create a Account, a contact is always linked to it.

So you get the Information of both (Contact as well as Account) from that person account.

for more refer Person Account details

also explain what you intend to do(which fields you want to extract from query on which object).

Dave Frankenbach @ EADave Frankenbach @ EA

Rahul - the question really isn't about the relationships between the contact and account objects. The question is why the workbench isn't allowing access to fields from both objects in a query. The simple query in the workbench documentation doesn't even work.

SabrentSabrent

select name, (select name from contacts) from account

 

gave me the correct result (as below), however it indeed seems line Workbench is not capable of  relationships in the form of  '__r' and  '.'

 

Query Results

Returned records 1 - 15 of 15 total records in 0.230 seconds:

  Name Contacts
1Art Van 
2Staples 
3Acme Stencils
  Name
1Ted Brown
2Megan Smith

4Mariott Club 5Grand Hotels & Resorts Ltd

  Name

1Tim Barr2John Bond6Express Logistics and Transport

  Name

1Babara Levy2Josh Davis7GenePoint

  Name

1Edna Frank8United Oil & Gas, UK

  Name

1Ashley James9United Oil & Gas, Singapore

  Name

1Tom Ripley2Liz D'Cruz

Dave Frankenbach @ EADave Frankenbach @ EA

rov - thanks for the confirmation.

 

df

altaiojokaltaiojok

The public instance of Workbench at https://workbench.developerforce.com has parent-relationship queries disabled due to a bug in the PHP SOAP engine that can cause results to appear in the wrong columns. Salesforce is sending back the query response correctly, but PHP has a problem processing the results when some rows have parents and others do not, so the feature is disabled rather than displaying potentially incorrect query results.

 

If you download Workbench and host it yourself, parent-relationship queries can be enabled, but with that known bug. Workbench can be downloaded at http://code.google.com/p/forceworkbench/

 

Workbench does support child-relationship queries in all instances, and many times queries can be re-written to use a child-relationship to achive a similar result. For example, instead of writing:

SELECT Id, Name, Account.Id, Account.Name FROM Contact WHERE AccountId != null

 

You could write:

SELECT Id, Name, (SELECT Id, Name FROM Contacts) FROM Account WHERE Id IN (SELECT AccountId FROM Contact)

Dave Frankenbach @ EADave Frankenbach @ EA

Ryan - thanks for the detailed explanation on why it's not working. When I run your second query I still end up getting a text value of "Array" output in the contact column rather than a list of the related contacts. Is there something else I need to configure in the workbench?

altaiojokaltaiojok

Dave -- That's very odd. Are you seeing "Array" on every row where a child-relationship would normally be? I attached a screenshot of what the results are supposed to look like. If so, that would suggest something like "grandchild records" being returned (which I don't think is possible) or something else Workbench is choking on in the results from your org. Would you be able to attach a screenshot of what you are seeing?

Dave Frankenbach @ EADave Frankenbach @ EA

Ryan - the workbench seems to be incompatible with IE8. In FF3.6 I see the related data. I don't find a list of supported browsers in the workbench docs. Do you know if IE9 is supported I really hate the the font rendering in FF.

altaiojokaltaiojok

There is not an official supported browser list for Workbench, but it generally works well with all major, modern browsers (FF, Chrome, Safari, IE8+). There are some known issues with IE8 in compatibility mode, but that is only with the query option labels, not the query results. I just tried a child relationship query in IE8 with both compatibility mode enabled and disabled, and they both display the results correctly on my end. If you are seeing differences in the query results depending on your browser, that is very odd because all the query result processing happens server-side and there isn't any special casing for particular browsers. Do you know if you have anything special configured in IE or in your org? Also, can you try toggling comtability mode and see if it does anything?

altaiojokaltaiojok

Actually I see some errors in the Workbench logs that might be related to this. Would be able to private message me your org id (you can get it from Session Info in Workbench) and I can see if it matches what I'm seeing?

Dave Frankenbach @ EADave Frankenbach @ EA

I was not using compatability mode on the developerforce site. If I turn it on I do see some overlapping page elements. I also still see the text Array rather than the child table. I don't quite have a default config set for IE8 because of some non-default values required by some other web based application we use. They don't conflict with other sites that I have noticed before this.

Ankit Gupta 2Ankit Gupta 2
Don't sweat man! Go to Workbench settings and enable "Allow Parent relationship queries". U'll get what u want.
Cheers.
PlaystationPlaystation
The "array" display problem in Workbench is (for some reason) related to the timezone setting.
If timezone in Workbench is changed from the default "UTC", related objects in queries appear as "array".
Guillermo Owen KankGuillermo Owen Kank
Great @playstation !!! never thought about that setting in workbench. Thanks a lot