1
votes

I could use some general assistance with a simple bit of Apex code. Just so you know I am a newbie to Salesforce.com, but not to web application programming (12 years but with Coldfusion and some Perl and am used to the MVC architecture), although I have not been exposed deeply to Java or C#.

So I am working on a simple controller that I'll use in a simple VF page. I'd just like to return the value and display it on the page but Im running into some syntax issues during compile. Here's my code so far:

Controller - mytest.cls

    public with sharing class myTest {

    public class addNewFolder {

        String tmpFolderName = 'MyTestFolder';
        String tmpObjectID = '22K22'; 

        String tmpResult = 'Whoo-hoo!';
        System.debug('XIX|' + tmpResult);
        return tmpResult;

    }

}

Error

Description Resource Path Location Type Save error: expecting a right parentheses, found 'XIX|' mytest.cls /PREPROD/src/classes line 15 Force.com save problem

2
You have code that's not in any method, you need to move your code into an actual method definition.superfell
Thanks - here's a link to the SF dev forum on the same subject. I believe you are correct @superfell: boards.developerforce.com/t5/Apex-Code-Development/…user891859

2 Answers

1
votes

As I understand

addNewFolder

is a METHOD. So instead of writing

public class addNewFolder

you must write public string addNewFolder() {... return tmpResult;}

I hope it will help you.

0
votes

It looks like the | character is causing the error. You could try escaping the | character like this:

System.debug('XIX\\|' + tmpResult);

Or, you could use a different character:

System.debug('XIX-' + tmpResult);

Update: Upon looking more carefully at your code, I realized superfell is right (see his comment on your question above).