Wednesday 29 August 2012

Creating an Apex Class Using the Salesforce User Interface


You can also create an Apex class in the Salesforce user interface.
  1. Click Your Name | Setup | Develop | Apex Classes.
  2. Click New.
  3. In the editor pane, enter the following code:
    public class MessageMaker {
    } 
  4. Click Quick Save. You could have clicked Save instead, but that closes the class editor and returns you to the Apex Classes list. Quick Save saves the Apex code, making it available to be executed, yet it also lets you continue editing—making it easier to add to and modify the code.
  5. Add the following code to the class:
    public static string helloMessage() {
        return('You say "Goodbye," I say "Hello"');
    }

    Creating an Apex class on the Apex Class Edit page.
  6. Click Save.
You can also view the class you’ve just created in the Developer Console and edit it.
  1. In the Developer Console, click the Repository tab.
  2. In the Setup Entity Type panel, click Classes, and then double-click MessageMaker from the Entities panel.
    The MessageMaker class displays in the source code editor. You can edit the code there by typing directly in the editor and saving the class.

No comments:

Post a Comment