• kanchan.123
  • NEWBIE
  • 25 Points
  • Member since 2010

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 1
    Replies

Hi,

 

I need to get the ContactId from the User object. 

 

I have written the following code for it.

 

 

List<User> lstUser = [Select u.Id,u.ContactId from User u where u.Id = :idUser];
            if( lstUser != null && lstUser.size() > 0 )
            {
                System.debug('lstUser[0].ContactId::' + lstUser[0].ContactId);
                return lstUser[0];
            }

 

List<User> lstUser = [Select u.Id,u.ContactId from User u where u.Id = :idUser];            

if( lstUser != null && lstUser.size() > 0 )            

{

      System.debug('lstUser[0].ContactId::' + lstUser[0].ContactId);

      return lstUser[0];

}

 

but the System.debug statement prints as null.

 

If i try to execute the same query in the Force.com IDE, i got the correct result.

 

Also my class is running in System mode. 

 

Can anybody please tell me what i am doing wrong here.?

 

Hi,

 

I need to get the ContactId from the User object. 

 

I have written the following code for it.

 

 

List<User> lstUser = [Select u.Id,u.ContactId from User u where u.Id = :idUser];
            if( lstUser != null && lstUser.size() > 0 )
            {
                System.debug('lstUser[0].ContactId::' + lstUser[0].ContactId);
                return lstUser[0];
            }

 

List<User> lstUser = [Select u.Id,u.ContactId from User u where u.Id = :idUser];            

if( lstUser != null && lstUser.size() > 0 )            

{

      System.debug('lstUser[0].ContactId::' + lstUser[0].ContactId);

      return lstUser[0];

}

 

but the System.debug statement prints as null.

 

If i try to execute the same query in the Force.com IDE, i got the correct result.

 

Also my class is running in System mode. 

 

Can anybody please tell me what i am doing wrong here.?