You need to sign in to do that
Don't have an account?
RedSales
Using System.debug('hello'); Gives "expecting a right parentheses" error?
Hello,
I'm new to Apex & in a clas I'm writing I want to print out debug statements at various steps however I can't seem to get these to work.
if I do
System.debug('hello');
I get an error as follows
Multiple markers at this line
- expecting a right parentheses, found 'hello'
- Save error: expecting a right parentheses,
found 'hello'
Does anyone have any ideas as to why this may be occuring? If I look at sample code online the above should work.
Hi,
I am assuming you are trying to call the method from outside a class method as in the code below:
In this case I get the error message you mention above.
Classes work like Java or C# classes.
You could on the other hand get away with the system.debug without a method in a trigger because triggers are like scripts.
Please review the Apex Developer guide and in particular the section which explains Apex classes:
http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_classes_understanding.htm
and the one which compares Apex to Java:
http://www.salesforce.com/us/developer/docs/apexcode/index_Left.htm#StartTopic=Content/apex_classes_java_diffs.htm?SearchType=Stem
and the one which explains triggers:
http://www.salesforce.com/us/developer/docs/apexcode/index_Left.htm#StartTopic=Content/apex_triggers.htm
All Answers
Hi,
I am assuming you are trying to call the method from outside a class method as in the code below:
In this case I get the error message you mention above.
Classes work like Java or C# classes.
You could on the other hand get away with the system.debug without a method in a trigger because triggers are like scripts.
Please review the Apex Developer guide and in particular the section which explains Apex classes:
http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_classes_understanding.htm
and the one which compares Apex to Java:
http://www.salesforce.com/us/developer/docs/apexcode/index_Left.htm#StartTopic=Content/apex_classes_java_diffs.htm?SearchType=Stem
and the one which explains triggers:
http://www.salesforce.com/us/developer/docs/apexcode/index_Left.htm#StartTopic=Content/apex_triggers.htm
Thanks for the help sebcos. Appreciated!