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
iSfdciSfdc 

Relationship (semijoin queries) not working

Hi,
Got stuck-up in a Semi-join query which is not working !
I have written  a query to select all the users under a Manager.I am not getting the output for this query, im getting an exception.
 
Code:
var users=sforce.connection.query("select FirstName,LastName from User where UserRoleId IN (Select Id from UserRole where ParentRoleId='00E20000000iMZD')");
 
Any pointers on this would help.
aamorosaamoros
This link should help clear up the SOQL Relationship Query.
http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_calls_soql_relationships.htm

http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_calls_soql_relationships.htm



Message Edited by aamoros on 11-25-2008 07:30 AM
werewolfwerewolf
In your REQUIRESCRIPT what version of the Ajax toolkit are you including?  Remember that you have to have at least 14.0 to be able to use semijoins.
iSfdciSfdc

Im using API 14.0 version only, duno where is the bug. if i execute them seperately its working.

i.e. fetching for isers'  details - working fine

i.e.fetching for Roles seperately - working fine

..When i combine into a semi join , its not working

SuperfellSuperfell
from the api docs

Main query limit: In the main WHERE clause, the left operand of any semi-join or anti-join query must query a single primary ID field. However, the selected field in a subquery can be a foreign key.
iSfdciSfdc
Considering that, it is violating the Foreign key rule, i have created one more query seperately, but even here IN is not working ..
 
 
Code:
 
var rolesusers=sforce.connection.query("Select Id from UserRole where ParentRoleId='00E20000000iMZD'");
roleuse=rolesusers.getArray('records');
 
var users=sforce.connection.query("select FirstName,LastName from User where UserRoleId IN ('"+roleuse.Id+"')");
 
 
SuperfellSuperfell
Your code doesn't make any sesne roleuse is an array, so what does roleuse.id return ?
aamorosaamoros

Hi UG,

Try this for a work around:

Code:
var users=sforce.connection.query("Select u.UserRoleId, u.LastName, u.FirstName From User u Where u.UserRole.ParentRoleId = '00E20000000iMZD'");


 

iSfdciSfdc
Thank you !! its working.Querying across multiple level of objects is good.