0

I'm trying to select user's subordinates from Salesforce, but a simple query

SELECT Id FROM User WHERE ManagerId=xxxxxxxxx

returns bunch of null values, when I run

SELECT Id,Name FROM User WHERE ManagerId=xxxxxxxx

I get the correct names, still no IDs.

Is this a permission issue? I can't find anything when I login to portal.

I'm running the queries via API on Sandbox environment.

gh0st
  • 214
  • 3
  • 15

2 Answers2

1

Try this (both works for me allways):

Id myId = [Select Id From User Where Username = 'myUserName'].Id;
System.debug('#### myId: ' + myId);

List<User> myIdList = [Select Id From User Where Username = 'myUserName' Limit 1];
System.debug('#### myId from list: ' + myIdList[0].Id);
mast0r
  • 820
  • 5
  • 13
  • Tried that, still getting Arrays with nulls – gh0st Aug 13 '12 at 14:32
  • Maybe try to catch the error? `try{ Id myId = [Select Id From User Where Username = 'myUserName'].Id; } catch(Exception e){ System.debug('#### error: ' + e.getMesage()); }` – mast0r Aug 13 '12 at 14:37
  • And check your profile, this settings must to be checked: Standard / Custom Object Permissions -> Read, View All – mast0r Aug 13 '12 at 15:01
  • Another settings for the systemadmin: Author Apex, View All Data, API Enabled – mast0r Aug 13 '12 at 15:04
  • Thanks for all the answer mast0r. Where can I change Standard / Custom Object Permissions? The User's account which I'm testing is of System Administrator type. So it should have all the permissions granted. – gh0st Aug 13 '12 at 15:50
1

Portal Licence doesn't allow to query User. However you have still access to the name of the user through OwnerId, CreatedById, LastModifiedById using in an inputfield.

i.e :

If you want to have access to user through the portal you need a custom object and synchronise your records with User by trigger.

brovasi
  • 167
  • 9