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
dujsudujsu 

Newbie Apex Question

Hello all,

 

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

 

 

Best Answer chosen by Admin (Salesforce Developers) 
SeAlVaSeAlVa

I believe that the piece of code that you are after is something like ...

 

 

public with sharing class myTest {
	public String getAddNewFolder() {
		String tmpFolderName = 'MyTestFolder';
		String tmpObjectID = '22K22'; 
		
		String tmpResult = 'Whoo-hoo!';
		System.debug('XIX|' + tmpResult);
		return tmpResult;
	}
}

 

Regards

All Answers

SeAlVaSeAlVa

I believe that the piece of code that you are after is something like ...

 

 

public with sharing class myTest {
	public String getAddNewFolder() {
		String tmpFolderName = 'MyTestFolder';
		String tmpObjectID = '22K22'; 
		
		String tmpResult = 'Whoo-hoo!';
		System.debug('XIX|' + tmpResult);
		return tmpResult;
	}
}

 

Regards

This was selected as the best answer
dujsudujsu

Thanks - that seems to work!

 

Calling that method with VF:

 

<apex:page controller="myTest"> 
  <apex:pageBlock title="This is a test page.">
  	{!addNewFolder}
  </apex:pageBlock>
</apex:page>

 

I just want to display the value of addNewFolder to the page now. The error I am receiving is "Unknown property 'myTest.addNewFolder'".

SeAlVaSeAlVa

Check my previous post, I've just update it.

dujsudujsu

That worked - thank you very much!