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
hometeamhometeam 

Initial term of field expression must be a concrete SObject: Id

What I'm trying to do is simply identify one of the system Admin Ids for my test class.  My code is below but I'm getting the above error on AdminID = users.Id;

 

  for (Profile Prof : [Select p.Name, (Select u.Id From Users u where u.IsActive = TRUE)
     From Profile p where p.Name = 'System Administrator']) {
   for (Id users : Prof.users){
    AdminId = users.Id;
    break;
   }
  }

Any help/suggestions would be appreciated.

Best Answer chosen by Admin (Salesforce Developers) 
bob_buzzardbob_buzzard

I think your problem that you have declared users to be an id in the for loop:

 

 

for (Id users : Prof.users){
    AdminId = users.Id;

 

 

Try changing this to :

 

 

for (User users : Prof.users){
    AdminId = users.Id;

 

 

 

All Answers

bob_buzzardbob_buzzard

I think your problem that you have declared users to be an id in the for loop:

 

 

for (Id users : Prof.users){
    AdminId = users.Id;

 

 

Try changing this to :

 

 

for (User users : Prof.users){
    AdminId = users.Id;

 

 

 

This was selected as the best answer
hometeamhometeam

Thank you!  That was the solution!