You need to sign in to do that
Don't have an account?
Savi3
Error while using System.debug
Hi,
I'm getting "Compile Error: unexpected token: ')' at line 19 column 22" while using System.debug.
I need to get the email of the logged in user. For that i wrote this code:
ID usrid = UserInfo.getUserId();
List<User> cusr = [Select Email From User where id =: usrid ];
String uEmail = cusr[0].Email;
System.debug(uEmail); ---------------------- (Line 19)
Can somebody tell me why this is happening and its solution? Please..
Thank you,
Savi3.
I got its answer....
We can use debug statements only in methods of a class...
public constructorforClass()
{
cusr = [Select Email From User where id =: usrid Limit 1];
uEmail = cusr.Email;
contmap = new Map<id,contact>([Select id,name from contact where EmailAddress__c = :uEmail]);
System.debug(uEmail);
}
Thank you,
Sav3
All Answers
As a newbie, I have been looking at the discussion boards and come across your post.
As the code stands, it compiles successfully with v24.
This may suggest the compiler error is being reported from another error in your class.
Using your example code.
I've added a controller wrapper and static method to allow me to call your code from the console
public class TestController
{
public static void LogMsg()
{
ID usrid = UserInfo.getUserId();
List<User> cusr = [Select Email From User where id =: usrid ];
String uEmail = cusr[0].Email;
System.debug(uEmail);
}
}
Using the console to execute the method:
TestController.LogMsg();
The raw log shows the call to LogMsg and the logging of your email address using the default DEBUG log type:
I got its answer....
We can't use debug statements only in methods of a class...
I got its answer....
We can use debug statements only in methods of a class...
public constructorforClass()
{
cusr = [Select Email From User where id =: usrid Limit 1];
uEmail = cusr.Email;
contmap = new Map<id,contact>([Select id,name from contact where EmailAddress__c = :uEmail]);
System.debug(uEmail);
}
Thank you,
Sav3